On Tue, Jul 1, 2008 at 6:27 AM, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "Kent Johnson" <[EMAIL PROTECTED]> wrote
>>>
>>>           if isinstance(x, list):
>>>               for item in x:
>>>                   x = item
>>
>> This just assigns x to the last element of the list
>
> Oops, yes, I said the first but in fact reassigning x does not stop the
> loop, it seems the loop works on a local copy of the original reference.

Under the hood, 'for item in x' creates an iterator which has a
reference to the original list.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to