Re: how to explain such codes, python's bug or mine?



"MaHahaXixi" <enjoy_linux@xxxxxxxxxxx> wrote:

> for python, i am a newbie, but i did not found the warning of such usage
> from the python tutorial

"4.2 for Statements"

"It is not safe to modify the sequence being iterated over in the loop (this
can only happen for mutable sequence types, such as lists). If you need
to modify the list you are iterating over (for example, to duplicate selected
items) you must iterate over a copy." (followed by an example)

</F>



.



Relevant Pages

  • Re: Function to remove elements from a list not working (corrected)
    ... The for loop maintains an internal loop variable, ... such as lists). ... To safely modify the list you are iterating over ...
    (comp.lang.python)
  • Re: Accessing next/prev element while for looping
    ... > The python way is much more succinct. ... > previous or the next element in the array before continuing iterating. ... > incredibly silly given that python lists under the hood are linked ... the iterator used by the for loop, not the list it is iterating over. ...
    (comp.lang.python)
  • Re: Vector or List
    ... > I'm fairly new to the STL and i was wondering when was the best situations ... to elements other than iterating over them ... For lists, ... I'm Schobi at suespammers dot org ...
    (microsoft.public.vc.stl)
  • Re: Iterator Class?
    ... > there is a significant performace penalty when using getfor long Lists. ... > It appears as though getinsists on iterating from the beginning of the ... > list to arrive at the desired element. ... the profiler has never complained about iterating over a 10 ...
    (comp.lang.java.programmer)
  • Re: Iterator Class?
    ... > there is a significant performace penalty when using getfor long Lists. ... > It appears as though getinsists on iterating from the beginning of the ... > list to arrive at the desired element. ... the profiler has never complained about iterating over a 10 ...
    (comp.lang.java.help)