[Tutor] Self, Scopes and my unbelievable muddleheadedness.

Luke Paireepinart rabidpoobear at gmail.com
Thu Oct 26 00:29:50 CEST 2006


>
> I'm sure this is so obvious that a crack-addled tapeworm head down in 
> a bucket of stupid could understand it, unfortunately, I'm not quite 
> at that level today. Sorry.
Uh, I don't understand why you're passing Fields to the functions but 
then putting the value in self.Fields...
but we'll ignore that for now :)

The problem it sounds like you're having is that you think that passing 
lists to functions copies them,
when in fact it just creates a reference to them.
Take this, for example:


 >>> def append_five(alist):
    alist.append(5)
 >>> a = [1,2,3,4]
 >>> append_five(a)
 >>> a
[1, 2, 3, 4, 5]
 >>> append_five(a)
 >>> a
[1, 2, 3, 4, 5, 5]


Other than that,
Maybe you think self is used for something other than what it's intended 
to be used for...
but I can't be sure.
I'm sure someone else can give you a good example.
I, however, have to run.
HTH,
-Luke



More information about the Tutor mailing list