Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
This isn't a bug. In Python 2, True and False are variable names rather than keywords. That means they can be shadowed: >>> False = 10 >>> True = 20 >>> [False, True] [10, 20] A Counter() is a kind a dictionary that returns zero rather than raising a KeyError. When you give eval() a Counter as a locals() dict, you're effectively shadowing the False and True variables: >>> eval('[False, True]', {}, Counter()) [0, 0] That follows from: >>> c = Counter() >>> c['True'] 0 >>> c['False'] 0 So effectively, your example translates to: >>> [0, 0, 0].count(0) 3 ---------- assignee: -> rhettinger nosy: +rhettinger resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37780> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com