Where do nested functions live?
agriff at tin.it
Sat Oct 28 16:17:42 CEST 2006
Fredrik Lundh wrote:
> Ben Finney wrote:
>> If you want something that can be called *and* define its attributes,
>> you want something more complex than the default function type. Define
>> a class that has a '__call__' attribute, make an instance of that, and
>> you'll be able to access attributes and call it like a function.
> I turned Steven's question and portions of the answers into a Python FAQ
> Hope none of the contributors mind.
I'd add that while in some respect "def x" is like
an assigment to x ...
>>> def f():
in some other respect (unfortunately) it's not a regular assignment
>>> x = object()
>>> def x.g():
SyntaxError: invalid syntax
More information about the Python-list