Appropriate use of Property()

noemailplease0001 at gmail.com noemailplease0001 at gmail.com
Wed Jan 30 02:17:36 CET 2008


Property() can be used to rid ourselves of the extra effort of using
two different methods (getAttrib() setAttrib()) for access of an
attribute without giving direct access to the attribute, thus making
it more elegant. So, the outsider using my module accesses the
attribute with the syntax 'Object.attrib', but since this syntax looks
as if he is accessing the attribute (rather than through a
descrtiptor), should we subscribe to this syntax only when the
attribute is both readable and writable? i.e.,
if I have an attribute which I strongly believe would always be only
readable, should I go with the old style 'Object.getAttrib()'?
Would like to know different perspectives.

Thanks,
K



More information about the Python-list mailing list