beginner, idiomatic python
bambam
david at asdf.asdf
Sun Aug 26 23:24:45 EDT 2007
Thank you, I have been through the tutorial several times, I guess
I'm just not smart enough. Python is quite different from the
languages I am familiar with.
My code sample started like this:
>>for i in range(self.parent.GetPageCount()):
I was asked:
>Does page count change? i.e. is it necessary to retrieve it in every loop
Is self.parent.GetPageCount() 'retrieved every loop'?
Steve.
"Scott David Daniels" <daniels at dsl-only.net> wrote in message
news:13d4elsj1so0ed3 at corp.supernews.com...
> 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