Problems with first try subclassing

Gerrit Holl gerrit at nl.linux.org
Wed May 21 16:06:00 EDT 2003


Gerrit Holl schreef op woensdag 21 mei om 21:54:20 +0000:
> 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 can compare it with:

def f(x):
    x = 3

x = y = 25
f(y)    # won't change y!
f(x)    # won't change x!

yours,
Gerrit.

-- 
102. If a merchant entrust money to an agent (broker) for some
investment, and the broker suffer a loss in the place to which he goes, he
shall make good the capital 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