python-2.1 function attributes

Moshe Zadka moshez at zadka.site.co.il
Sun Jan 28 01:15:37 EST 2001


On 27 Jan 2001 15:53:39 -0800, aahz at panix.com (Aahz Maruch) wrote:
 
> One thing I'm not clear on from all this discussion is whether one can
> do this:
> 
> def f():
>     f.a = 1

Of course!

Python 2.1a1 (#2, Jan 27 2001, 21:08:11)
[GCC 2.95.3 20010111 (prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> def f():
...     f.a=1
...
>>> f.a
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: a
>>> f()
>>> f.a
1

-- 
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!
Fingerprint: 4BD1 7705 EEC0 260A 7F21  4817 C7FC A636 46D0 1BD6




More information about the Python-list mailing list