2.2 features
Jeff Shannon
jeff at ccvcorp.com
Wed Jul 25 13:56:55 EDT 2001
Tom Good wrote:
> "Nick Perkins" <nperkins7 at home.com> wrote in message
>
> > How about generators, who's tried them out?
>
> [snip]
>
> I like generators a lot. Here's a fun one:
>
> #------ begin code
> [snip]
> if __name__ == "__main__":
> g = fib()
> for i in range(9):
> print g.next(),
>
> #------ end code
Haven't looked into this in detail, or even downloaded 2.2 yet, but...
couldn't that be written as:
if __name__ == '__main__':
for i in fib():
print i,
???
(being under the impression that the main point of iterators is convenient for-loop usage...)
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list