This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author david2
Recipients david2
Date 2021-11-22.07:29:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1637566148.02.0.0346956477094.issue45862@roundup.psfhosted.org>
In-reply-to
Content
Hi

Example "eg def2" works but "eg def4" gives an error?

David

```
emp = [
    {
        "empno": 7839,
        "mgr": 0,
        "ename": "KING"
    },
    {
        "empno": 7566,
        "mgr": 7839,
        "ename": "JONES"
    },
    {
        "empno": 7698,
        "mgr": 7839,
        "ename": "BLAKE"
    }
]

a = [e for e in emp if e["mgr"] == 0]
print('eg 1', [b for b in a])
print('eg 2', eval('[b for b in a]'))
print('eg 3', [e for e in emp for b in a if e["mgr"] == b["empno"]])
print('eg 4', eval('[e for e in emp for b in a if e["mgr"] == b["empno"]]'))


def eval_anomaly():
    a_anomaly = [e for e in emp if e["mgr"] == 0]
    print('eg def1', [b for b in a_anomaly])
    print('eg def2', eval('[b for b in a_anomaly]'))
    print('eg def3', [e for e in emp for b in a_anomaly if e["mgr"] == b["empno"]])
    print('eg def4', eval('[e for e in emp for b in a_anomaly if e["mgr"] == b["empno"]]'))

eval_anomaly()
```
History
Date User Action Args
2021-11-22 07:29:08david2setrecipients: + david2
2021-11-22 07:29:08david2setmessageid: <1637566148.02.0.0346956477094.issue45862@roundup.psfhosted.org>
2021-11-22 07:29:08david2linkissue45862 messages
2021-11-22 07:29:07david2create