property, how to use it?
Steve
lonetwin at gmail.com
Fri May 13 08:53:21 EDT 2005
Hi,
Read this:
http://www.python.org/2.2.3/descrintro.html#property
If you still don't understand or are confused about it's usage, ask here.
Hint: Suppose you need to create an Age class with a 'years' attribute
and ensure that, (assuming I create an object a = Age())
1) when one tries to access 'a.years', a '0' would be returned even if
the value was not set or was set to a negative value, and
2) If a value is assigned to the 'years' attribute, we should check
for negative values.
HTH
Regards
Steve
More information about the Python-list
mailing list