Constants and Globals
Pierre Rouleau
prouleau_nospam at impathnetworks.com
Mon Dec 16 12:21:57 EST 2002
>>>>>a.version = 0
>>>>
>>Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> File "protect.py", line 107, in writeAccess
>> raise self.AccessError, "Can not rebind attribute"
>>AccessError: Can not rebind attribute
>>
>
>>>>a.__class__.version = 3
>>>>a.version
>>>
> 3
Thnaks for pointing this out.
>
> There is no way to make a truly read only variable in python.
> (Which is a good thing)
And why is this a good thing? If something is not meant to be
modifiable in a class, why not being able to make it constant? Python
has immutable things. so why not have the ability to have constant things?
Pierre
More information about the Python-list
mailing list