Problems with first try subclassing
Gerrit Holl
gerrit at nl.linux.org
Wed May 21 15:51:01 EDT 2003
Driver, David schreef op woensdag 21 mei om 21:40:46 +0000:
> def LoadMyDate(self,m): self=(m[:4],m[4:6],m[6:8])
You are now binding a new value to the name self. You are
overwriting the name. When LoadMyDate is executed, a reference
to the object is copied: the reference that the caller uses
still exists, and doesn't change.
You either want to try something like:
* return self(m[:4], m[4:6], m[6:8])
* or self.month = m[...] etc.
To see how the second should be done, you'd need to know what
names the date class uses to store the month, etc. internally.
Succes!
yours,
Gerrit.
--
101. If there are no mercantile arrangements in the place whither he
went, he shall leave the entire amount of money which he received with the
broker to give to the merchant.
-- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
http://www.sp.nl/
More information about the Python-list
mailing list