[Tutor] user-given variable names for objects
Kent Johnson
kent37 at tds.net
Sat Dec 15 17:57:29 CET 2007
Tiger12506 wrote:
>> Mmm, to nit-pick a little, dictionaries are iterables, not iterators. They
>> don't have a next() method.
>
> I'm a little fuzzy on the details of that, I will have to look over some
> reference material again.
An iterable is something that produces an iterator when you call iter()
on it. An iterator has a next() method. More here:
http://personalpages.tds.net/~kent37/kk/00004.html
> Oh! This is new to me! When did they put in itervalues? See what happens
> when you leave the python community so you can learn C and assembly~
Python 2.2, when explicit iterators were introduced.
>> and of course if you care about efficiency you should hoist the call to
>> time.time() out of the loop!
>
> Oh, I thought it was necessary for the time to change within the loop which
> might or might not be necessary
Yes, the functionality is slightly different if the time() call is
hoisted out of the loop.
Kent
More information about the Tutor
mailing list