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

Eric Brunson brunson at brunson.com
Wed Nov 7 22:37:19 CET 2007


John Fouhy wrote:
> 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..
>
>   
I'd like to see it, too.  I'll admit, I didn't finish reading your post, 
so I missed replying to that, but honestly I don't think it should do 
what you say it does.

:-)



More information about the Tutor mailing list