Do I always have to write "self." ?

Michael Hudson mwh21 at cam.ac.uk
Fri Apr 28 09:05:57 EDT 2000


"Louis M. Pecora" <pecora at anvil.nrl.navy.mil> writes:

> In the above I would describe things as follows (am I right or wrong?):
> 
> (1) data and self.data point to the same object, a list, so when a
> method is called it is the method that works on that instance of a list
> and either data or self.data will append 'foo' to the same list object.
> 
> (2) when you do more=more+1 an new object (the more+1 value) is created
> and more then points to it and no longer to the old value of self.more. 
> The latter still exists and points to the original 10 object.
> 
> (3) Similar story here for interesting where a new object
> interesting[10:] is created and interesting is "switched" to point to
> it.  self.interesting still points tohe "foo" object.
> 
> I hope I got that right, because they have tripped me up a few times.

Yes!  That's right.  Simple isn't it (once you understand, anyway)?

Cheers,
M.

-- 
  If i don't understand lisp,  it would be wise to not bray about
  how lisp is stupid or otherwise criticize, because my stupidity 
  would be archived and open for all in the know to see.
                                               -- Xah, comp.lang.lisp



More information about the Python-list mailing list