Reputation: 29
Code won't run from pydev console but runs fine when I start python in terminal
m = [{'x1': 8183.79980469, 'x2': 9113.79980469, 'y': None, 'side': 'LH'}, {'x1': 29723.09960938, 'x2': 30653.09960938, 'y': None, 'side': 'LH'}, {'x1': 30657.40039062, 'x2': 31587.40039062, 'y': None, 'side': 'LH'}, {'x1': 30657.4, 'x2': 31587.4, 'y': None, 'side': 'RH'}]
side = 'LH'
[i['x1'] for i in m if i['side'] == side]
Traceback (most recent call last):
File "/Applications/Eclipse.app/Contents/Eclipse/plugins/org.python.pydev.core_8.1.0.202012051215/pysrc/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "<console>", line 1, in <module>
File "<console>", line 1, in <listcomp>
NameError: name 'side' is not defined
I am on a mac running eclipse Version: 2020-12 (4.18.0) Build id: 20201210-1552, PyDev for Eclipse 8.1.0.202012051215 and Python 3.8.0
What am I missing here? How do I fix it?
Upvotes: 1
Views: 125
Reputation: 25332
What console are you talking about? Is this a debug console, an interactive console? Can you send a screenshot?
As a note, I'm not able to reproduce it (I tested it in both the debug console and the interactive console):
As a note, if you have things inside a method with other things defined, you may be hitting the issue in Python which @codewelldev mentioned (https://stackoverflow.com/a/23032799/13911868)
Upvotes: 1