list.remove for Novices

phil hunt philh at comuno.freeserve.co.uk
Sun Nov 25 19:14:37 EST 2001


On Sun, 25 Nov 2001 16:02:52 -0500, Tim Peters <tim.one at home.com> wrote:
>[Arthur Siegel]
>> I see that my -
>>
>> >>>foo = [1, 2, 3, 4, 5]
>> >>>for bar in foo:
>> ...        foo.remove(bar)
>>
>> issue which I ran into trying to follow suggestions for
>> my permutations problem was addressed beginning at:
>>
>> <mailman.1002041942.4167.python-list at python.org>
>
>That looks like an email address; it's unclear what it refers to.
>
>> But damn it to hell. Even when I try to be a normal Python
>> guy, and just post up "technical" problems, I get into-
>> or raise - issues/controversary.
>>
>> Because I am being asked to accept that the list.remove
>> behavior is somehow apparent - rather than a true
>> trap for the novice.
>
>I expect every newbie gets bit by this at least once.

I've not been bitten by it up to now.

(Or maybe I was, such a long time ago when I was learning programming,
and I've since internalised the idea that it is undefined if you
adjust the parameters of a for-loop inside the loop)


-- 
*** Philip Hunt *** philh at comuno.freeserve.co.uk ***




More information about the Python-list mailing list