On 4 May 2007 12:59:39 -0700, Michael <[EMAIL PROTECTED]> wrote: > On May 4, 9:19 am, John Nagle <[EMAIL PROTECTED]> wrote: > > > ... def g(): > > > ... x = x + 1 > > > > Too cute. Don't nest functions in Python; the scoping model > > isn't really designed for it. > > How can you make generators then if you don't nest? >
There's all kinds of good reasons to nest functions, and the "scoping model isn't really designed for it" somewhat overstates the case - it's not relevant to many of the reasons you might nest functions, and it's not (much) of a problem for the rest of them. What you can't do is rebind values in the enclosing scope, unless the enclosing scope is global. That's a real, but fairly minor, limitation and you'll be able to explicitly address your enclosing scope in 3k (or perhaps sooner). -- http://mail.python.org/mailman/listinfo/python-list