Re: dumping generator

2010-08-09 Thread Rob Williscroft
targetsmart wrote in news:cd83533b-f51e-4955-96c5-f8a10185bef1 @i18g2000pro.googlegroups.com in gmane.comp.python.general: > Right now if I want to dump the contents of a generator object I use , > a snip from a bigger block of code.. > > try: > while gen: print gen.next() > except StopIteratio

Re: dumping generator

2010-08-09 Thread Ulrich Eckhardt
targetsmart wrote: > Right now if I want to dump the contents of a generator object I use , > a snip from a bigger block of code.. > > try: > while gen: print gen.next() > except StopIteration: > print "Done" > else: > raise > > is there a much simpler way ? Why not something like this: f

Re: dumping generator

2010-08-09 Thread Peter Otten
targetsmart wrote: > Right now if I want to dump the contents of a generator object I use , > a snip from a bigger block of code.. > > try: > while gen: print gen.next() > except StopIteration: > print "Done" > else: > raise > > is there a much simpler way ? Indeed there is: for item in ge