Breakpoints not triggering on some lines of multi-line container assignment

def foo(x, y):

# does not stop
a = [

# does not stop
d = {
1 : x,
2 : y

# stops
s = sum(

# stops
n = [x,y]

# stops
r = {1:x, 2:y}

return x + 1, y + 2, s, a, n, r, d

q = foo(4,8)

Given the example above, breakpoints set at the first line of each assignment would not trigger for multi-line containers. Breakpoints would only trigger if they were set to a line containing an item. This is not the case for function calls.

PyCharm 2018.3.1 with Python 3.7

1 comment
Comment actions Permalink

I think it has nothing to do with objects declared using multiple lines, but with the fact that break point is meaningless if it's on the line that doesn't do anything.


For example

This won't trigger a breakpoint set on the first line:

a = [

But this will:

a = [1

So a line just containing `a = [` is not doing anything by itself, so the break point is not triggered.

This explanation might not be entirely correct, so if anyone have more information regarding how breakpoints work in Python, please share.


Please sign in to leave a comment.