Function calling another function

Diez B. Roggisch deets_noospaam at web.de
Mon Mar 1 17:14:53 EST 2004


> My question is surely a basic one, but somehow, I am not able to figure it
> out.
<snip>
> When I execute satish.py, main() executes. I was expecting y() to execute
> first and then x() and then y() again. I wanted function x() to be capable
> of calling function y(). With this form of code, seems like function x()
> is not recognising function y(). Is there any sort of import or anything
> else that I can do here ??

Works for me:

def main():
    y()
    x()


def y():
    print "y"

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

main()

gives me:


x
y
x

As expected.
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list