Closed TheChymera closed 6 years ago
The figure creation code is run via exec()
, and it seems that that is introducing scoping issues. See https://stackoverflow.com/a/45132815/2002379.
The only feasible fix I have found is to not use list comprehensions and go for loops instead. Please comment if you find a better suggestion.
e8bbb85ba122d2b1dd7d423d217b8f88a842c086 demonstrates a very weird bug I have come across. PythonTeX will report that all variables inside a list comprehension - except for the iterator - cannot be found. This behaviour does not occur when I execute the script with the Python interpreter, or when I run it via exec (which is how the RepSeP function runs it).
Here's what the error looks like (reproducible via the cloned RepSeP):
I wasn't able to reproduce this bug in any other way outside of PythonTeX. @gpoore could you help me figure this out? This issue occurs on Python3.4 and not on Python2.7 (haven't tested other versions) - but again, only when the code is executed via PythonTeX. apparently >Python3.2 has some quirky namespace management for list comprehensions - but this only manifests inside classes. Is my code by any chance executed via
class Pytxcode(object)
? Could this be the culprit? Is there any way to avoid this? ^^