Message377616
The attached file implements a custom dict-like class (MyDict) as a minimal example of code I am using in a larger codebase.
Before you ask, why I reimplemented a dict-like object: The real code base employs a hierarchical dict, referencing recursively to the parent dict, if a key cannot be found in the current dict.
The main code of the file defines two entries/variables for this dict:
symbols = MyDict()
symbols['abc'] = '[1, 2, 3]'
symbols['xyz'] = 'abc + abc'
and eval_text('xyz', symbols) should evaluate to the python expression as you would have evaluated those variables in a python interpreter.
While this works for the first given expression (above), it fails for this one:
symbols['xyz'] = '[abc[i]*abc[i] for i in [0, 1, 2]]'
raising NameError: name 'abc' is not defined.
The same code works perfectly in python 2.7. Hence, I assume this is a bug in python3. |
|
Date |
User |
Action |
Args |
2020-09-28 19:12:20 | Robert Haschke | set | recipients:
+ Robert Haschke |
2020-09-28 19:12:20 | Robert Haschke | set | messageid: <1601320340.36.0.581578891193.issue41878@roundup.psfhosted.org> |
2020-09-28 19:12:20 | Robert Haschke | link | issue41878 messages |
2020-09-28 19:12:20 | Robert Haschke | create | |
|