On 5/28/22, Chris Angelico <ros...@gmail.com> wrote: > > be extremely confusing; so to keep everything safe, the interpreter > generates a name you couldn't possibly want - same as for the function > itself, which is named "<listcomp>" or "<genexpr>", angle brackets > included.
To clarify, "<listcomp>" is the co_name and co_qualname value of the code object, which was compiled for the list comprehension. These names are also used as the __name__ and __qualname__ of the temporary object that's created by MAKE_FUNCTION. They are not identifiers. The code object is a constant, which is referenced solely by its index in the co_consts tuple. The temporary function is referenced on the stack. -- https://mail.python.org/mailman/listinfo/python-list