Bug or feature?

Gerson Kurz gerson.kurz at t-online.de
Sun Sep 2 01:33:38 EDT 2001


On Sat, 1 Sep 2001 15:25:31 -0400, "Tim Peters" <tim.one at home.com>
wrote:

>Neither, really -- it's just the way it works.  A def in Python is an
>executable stmt, and, when executed, binds the name following the "def" to
>the appropriate code object, in the appropriate namespace.  

Hey, the more I dive into python the more cool things it has. This
makes writing

def a(x):
    ...
def b(x):
    ...
b,a = a,b

possible :) And even this works as expected:

funcs = []
def a():
    print "code 1"
funcs.append(a)    
def a():
    print "code 2"
funcs.append(a)
for func in funcs: func()





More information about the Python-list mailing list