Nathaniel Smith <n...@pobox.com> added the comment: What should happen for:
def f(): if random.random() < 0.5: a = 1 b = 2 else: b = 1 a = 2 return locals() ? Right now co_varnames preserves the order that names were encountered when compiling, so it'd be easy to make 'a' come before 'b' in locals(), so the above function returns either {'a': 1, 'b': 2} or {'a': 2, 'b': 1}. If we want to preserve the illusion that local variables are entries in the locals() dict, though, then the dict ought to be either {'a': 1, 'b': 2}, {'b': 1, 'a': 2}. Making this happen would require extra machinery for an extreme edge case so I'm guessing it's not worth it though. ---------- nosy: +njs _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32690> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com