Function calling another function

  • Thread starter Satish Chimakurthi
  • Start date
S

Satish Chimakurthi

Hi all,

My question is surely a basic one, but somehow, I am not able to figure it out.

I have a python file "satish.py" as follows:


*satish.py*
def main():
y()
x()


def y():
..
..

def x():
...
..
y()

main()


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 ??



Thanks in advance for your help

Regards,
Satish


SATISH KUMAR CHIMAKURTHI
Graduate Research Assistant
CFD GROUP
Mechanical Engineering
UNIVERSITY OF KENTUCKY
Lexington
KENTUCKY - 40508
U.S.A

Email: (e-mail address removed)
Mobile:859-420-9890
Office: 859-257-6336 X 80691
 
D

Diez B. Roggisch

My question is surely a basic one, but somehow, I am not able to figure it
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.
 
S

Satish Chimakurthi

Hi all,

Thanks a lot and sorry. It was an indentation mistake. Caused havoc for 30
mins for me.


Thanks again

Regards,
Satish


----- Original Message -----
From: "Diez B. Roggisch" <[email protected]>
Newsgroups: comp.lang.python
To: <[email protected]>
Sent: Monday, March 01, 2004 4:14 PM
Subject: Re: Function calling another function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top