beginner, idiomatic python
Scott David Daniels
daniels at dsl-only.net
Sun Aug 26 22:45:45 EDT 2007
bambam wrote:
> That is, is it defined what Python does for
> for i in f()
> I'm sure it must be, but I haven't seen it yet. If I have
> a user defined function returning a range, is it defined
> that the range function is called on every loop? If I
> have a function returning a range taking a parameter,
> for i in f(v)
> is it defined that the variable is evaluated for every loop?
Nope. Take the tutorial.
for i in f(v):
<suite>
is the same as:
iterator = iter(f(v))
for i in iterator:
<suite>
-Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list