lambda in list comprehension acting funny

Chris Angelico rosuav at
Sun Jul 15 10:44:09 CEST 2012

On Sun, Jul 15, 2012 at 6:32 PM, Steven D'Aprano
<steve+comp.lang.python at> wrote:
> At compile time, Python parses the source code and turns it into byte-
> code. Class and function definitions are executed at run time, the same
> as any other statement.

Between the parse step and the 'def' execution, a code object is
created. When you call it, that code object already exists. Nothing
else really matters, unless there's a bug in the Python optimizer or
something weird like that. The nearest thing Python _has_ to a
"compile time" is the execution of def.


More information about the Python-list mailing list