Function calling another function

Jeff Epler jepler at unpythonic.net
Mon Mar 1 22:29:59 CET 2004


Code very much like yours works fine here.
One reason it might not work in your case is if the "..." part of 'def
x()' creates a local variable named y.

    $ cat /tmp/basic_one.py
    def main():
        y()
        x()

    def y():
        print "y"

    def x():
        print "x"
        y()

    main()
    $ python /tmp/basic_one.py
    y
    x
    y

Jeff




More information about the Python-list mailing list