IntelliJ/PyCharm Debugging with Conditional Breakpoint: Function parameter not defined

Viewed 162

I am observing the following weird behavior in IntelliJ 2020.03 with Python 3.9 on a Mac (but this also occurrs on another IntelliJ Version on an Ubuntu system).

If we consider the following minimal example:

def foo(bar):
   pass

foo(False)

Now I set a conditional breakpoint in IntelliJ in line 2 that conditions on:

[bar for _ in range(1)]

When I now run the script in debug mode, I get an error:

Error while evaluating expression: [bar for _ in range(1)]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <listcomp>
NameError: name 'bar' is not defined

So my question is simple: Why is bar not defined in the generator? (The crucial point to reproduce is to reference bar in some generator, otherwise it is defined (of course?)

1 Answers
Related