[Tutor] In-place expansion of list members... possible?

John Fouhy john at fouhy.net
Wed Nov 7 22:06:06 CET 2007


On 08/11/2007, Marc Tompkins <marc.tompkins at gmail.com> wrote:
> Now, I did already (intellectually) understand this:
>   A list is an array of pointers to objects, what you've done here is
>   create a new name referencing an item in the list, then making that new
>   name point to something different.
> Given that, however, I still don't entirely understand why the other
> examples I gave DO work.  Seems it should be one or the other, no?

Could you post some code/results (or an interpreter session) showing
one of the other examples working?

If you did, for example,

        tmpSegs = inString.split(self.SegTerm)
        for seg in tmpSegs:
            seg = 'bananas'

I would expect tmpSegs to be unchanged.  If it is changed, then that
seems strange to me..

-- 
John.


More information about the Tutor mailing list