[Tutor] Class attributes not overriding parameters
Jan Eden
lists at janeden.org
Sun Nov 6 10:42:03 CET 2005
Hi Liam,
Liam Clarke wrote on 06.11.2005:
>Hi Jan,
>
>Won't this
>
>site_id = property(GetSiteID, SetSiteID)
>
>and this
>
>site_id = 1
>
>collide?
>
Yup. After writing my message, I thought about it again: the property function gets never executed when I use the class attribute.
So I changed the setup to this:
class Base:
def GetSiteID(self):
return self._site_id
def SetSiteID(self, value):
if not (hasattr(self, '_site_id') and self._site_id): self._site_id = value
site_id = property(GetSiteID, SetSiteID)
class Lists(Base):
...
class SiteList(Lists, Data.Lists):
_site_id = 1
which works just as expected. Thanks for yor help!
- Jan
--
A core dump is your computer's way of saying "Here's what's on my mind, what's on yours?"
More information about the Tutor
mailing list