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: sk*****@engr.uk y.edu
Mobile:859-420-9890
Office: 859-257-6336 X 80691 2 2387
> 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
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" <de************ @web.de>
Newsgroups: comp.lang.pytho n
To: <py*********@py thon.org>
Sent: Monday, March 01, 2004 4:14 PM
Subject: Re: Function calling another function 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 -- http://mail.python.org/mailman/listinfo/python-list This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eric Entressangle |
last post by:
Hi all,
is there any trouble setting an C++ static class method as callback
function for a C program or library ?
Thanks
|
by: Roland Hall |
last post by:
Is there a way to return multiple values from a function without using an
array? Would a dictionary object work better?
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script...
|
by: Foxy Kav |
last post by:
Hi everyone, im a first year UNI student doing a programming subject
and im stuck on how to get rid of my global variables, char
stringarray and char emptystring. I was wondering if
anyone could show me a example of how to do this. I was told to pass
the arrays from function to function, but i do not know how ....
Thanxs if you can help.
...
|
by: amit kumar |
last post by:
I am calling a function which returns pointer to a map.
The declaration of the map is map<int,vectxyz*>. vectxyz is a vector
containing pointer to a class xyz.
For map<int,vectxyz*>* p1
In the called function, I am using p1->find(1) which is returning a
valid iterator and not going to the end. I am returning p1 from the
called function.
...
|
by: Muthu |
last post by:
I've read calling conventions to be the order(reverse or forward) in
which the parameters are being read & understood by compilers.
For ex. the following function.
int Add(int p1, int p2, int p3);
The parameters here can be read either in the forward order from p1
till p3 or reverse order from p3 till p1.
Can anyone explain what is the...
| |
by: pakis |
last post by:
I am having a problem of pure virtual function call in my project.
Can anyone explaine me the causes of pure virtual function calls other than
calling a virtual function in base class?
Thanks
|
by: Felix Kater |
last post by:
Hi,
I can compile and run this code (see below) which twice calls the
function f, first with too less, second with too much arguments.
But is it legal and free of memory leaks and other problems? Of course,
I presume that inside f I don't access i in case it was called via g.
int f(int i){ /* ... */ return 0; }
|
by: dspfun |
last post by:
Hi,
Is it possible to print the function name of the calling function?
For example, f1() and f2() both calls f3(), in f3() I would like to
print the name of the function calling f3() which could either be f1()
or f2().
BRs!
|
by: william |
last post by:
My situation is here:
an array of two dimension can only be defined locally within a
function(because the caller don't know the exact size ). Then the
question is: how should the caller access this array for future use?
The code is:
**********************
caller()
{
|
by: Morten Lemvigh |
last post by:
Is it possible to pass a pointer to a constructor or a class definition
as argument to a function? Maybe in a way similar to passing function
pointers...?
The function should construct a number of objects using the given
constructor. The objects should all inherit from a base class.
It's not possible to pass actual objects, since it's not...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |