Invisible function attributes

Olivier Lefevre lefevrol at
Wed Sep 3 17:15:45 CEST 2003

Python 2.3
>>> def foo():
...     foo.a = 1
>>> vars(foo)
>>> foo()
>>> vars(foo)
{'a': 1}

So it would appear that function attributes are not really
there until the first call to the function. If that is the
intended behaviour, it is really weird. I couldn't find any
explicit discussion of this topic in the LRM.

Thanks if anyone can shed some light on this,

-- O.L.

More information about the Python-list mailing list