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 > entry: > > http://effbot.org/pyfaq/where-do-nested-functions-live.htm > > Hope none of the contributors mind.
I'd add that while in some respect "def x" is like an assigment to x ... >>> def f(): global g def g(): return "Yoo!" >>> f() >>> g() 'Yoo!' in some other respect (unfortunately) it's not a regular assignment >>> x = object() >>> def x.g(): SyntaxError: invalid syntax >>> Andrea -- http://mail.python.org/mailman/listinfo/python-list