Implementing class attribute access methods via pseudo-function o verloading.
Daniel Dittmar
daniel.dittmar at sap.corp
Mon Oct 25 07:13:03 EDT 2004
Doran_Dermot at emc.com wrote:
> def title( self, title=None ):
> if title == None:
> return self._title
> self._title = title
You probably meant
def title( self, title=None ):
if title == None:
return self._title
else:
self._title = title
or every read access would clear the attribute.
1. Some people dislike methods that do very different things depending
on the parameters. These are difficult to explain. Though in your case,
one central explanation and links from all the methods should be enough.
2. None is often a useful value, so perhaps you should use a module
local variable like _GetValue (actual value is irrelevant)
def title (self, title = _GetValue):
Daniel
More information about the Python-list
mailing list