Re: Interesting little "gotcha" with generators

2005-12-22 Thread Aahz
In article <[EMAIL PROTECTED]>, Paul Rubin wrote: >[EMAIL PROTECTED] (Aahz) writes: >> >> What's wrong with >> >> def foo(): >> if False: yield None > >Does the following work? > >def foo(): >raise StopIteration Nope. -- Aahz ([EMAIL PROTECTED]

Re: Interesting little "gotcha" with generators

2005-12-22 Thread Paul Rubin
[EMAIL PROTECTED] (Aahz) writes: > What's wrong with > > def foo(): > if False: yield None Does the following work? def foo(): raise StopIteration -- http://mail.python.org/mailman/listinfo/python-list

Re: Interesting little "gotcha" with generators

2005-12-22 Thread Will McGugan
Kenneth McDonald wrote: > I recently had need to write the following code: > > def compileOuter(self): > if False: yield None > else: return > > "compileOuter" is a generator function which is implemented in various > classes. In this particular class, it always yields nothi

Re: Interesting little "gotcha" with generators

2005-12-22 Thread Aahz
In article <[EMAIL PROTECTED]>, Kenneth McDonald <[EMAIL PROTECTED]> wrote: > >I recently had need to write the following code: > > def compileOuter(self): > if False: yield None > else: return What's wrong with def foo(): if False: yield None -- Aahz ([EMAIL PRO

Re: Interesting little "gotcha" with generators

2005-12-22 Thread Duncan Booth
Kenneth McDonald wrote: > I recently had need to write the following code: > > def compileOuter(self): > if False: yield None > else: return > > "compileOuter" is a generator function which is implemented in > various classes. In this particular class, it always yields n

Interesting little "gotcha" with generators

2005-12-22 Thread Kenneth McDonald
I recently had need to write the following code: def compileOuter(self): if False: yield None else: return "compileOuter" is a generator function which is implemented in various classes. In this particular class, it always yields nothing. However, none of the following