Invisible function attributes

Terry Reedy tjreedy at udel.edu
Wed Sep 3 12:25:50 EDT 2003


"Olivier Lefevre" <lefevrol at yahoo.com> wrote in message
news:51809ae4.0309030715.7706cadb at posting.google.com...
> Python 2.3
> >>> def foo():
> ...     foo.a = 1

If you want foo to be attributed before it is called, move the setter
outside the function.

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

Terry J Reedy






More information about the Python-list mailing list