Using properties

alex23 wuwei23 at gmail.com
Wed May 25 21:29:38 EDT 2005


tkpmep at hotmail.com wrote:
> Thanks for the help. I now understand it better. As Bruno points out, I
> really don't need a property in this case, as my attribute is public,
> and I will remove it.

Should you need it to be a property at a latter date, it's worth noting
that you can achieve what you were initially after by wrapping the
property's get/set around the objects '__dict__' attribute:

    def getname(self): return self.__dict__['name']
    def setname(self): self.__dict__['name'] =newname

Hope this helps.

-alex23




More information about the Python-list mailing list