True. That is why I have now reverted back to use list whenever possible. As while list can also be modified(say in a multi-thread situation), at least if I don't do the update(coding policy, practice or whatever), they are sort of "guaranteed".
I would only use generator as IO monad in Haskell, i.e. don't use it unless I absolutely need to. Diez B. Roggisch wrote: > > Its a question of protocol. A iterator only guarantes that you can fetch > items from it until it is possibly exhausted. In the same way, a stream > may only guarantee you that you can read from it. If you need more, you > have tgo use a different protocol. Lists are one that allows you to > randomly access it. Files allow to seek, in addition to stream semantics. > > And given that python is an imperative language with side-effects, you > don't know what sideeffects a generator can cause - which makes a > "rewind" or copy-semantics to make it work several time impossible (in > the general case, that is). So it has to focus on what it _can_ guarantee. > > Haskell and other FP languages canwork differently here, as sideeffects > are made excplicit using e.g. monads or other means - which allows for > re-use of a generator-like construct. But there is no way to make this > work in pythons paradigm. > > Diez -- http://mail.python.org/mailman/listinfo/python-list