Interesting little "gotcha" with generators

Aahz aahz at pythoncraft.com
Thu Dec 22 17:13:01 EST 2005


In article <mailman.2464.1135288475.18701.python-list at python.org>,
Kenneth McDonald  <kenneth.m.mcdonald at sbcglobal.net> 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 (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck."  --USENET schmuck (aka Robert Kern)



More information about the Python-list mailing list