Why I hate lambdas (Re: Do any of you recommend Python as afirst programming language?)

Arnaud Delobelle arnodel at googlemail.com
Mon Mar 24 10:41:16 EDT 2008


On Mar 24, 2:01 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
[...]
>
> Yes, but what I'm asking is why the code objects have a co_name
> attribute. And even if there's a good reason for code objects to have a
> name, why do tracebacks use func.func_code.co_name instead of
> func.__name__?

From what I remember when I looked at the source: stack frames execute
code objects, not functions.  They don't know what function has
spawned them, only what code object they are executing.  In fact when
one thinks of it, it makes more sense for code objects to have a name
(taken from the def statement) than for function objects, as there is
exactly one code object for every def statement.

--
Arnaud




More information about the Python-list mailing list