[Tutor] Importing global variables and classes from other modules

Venkatesh Babu vbabu at cse.iitk.ac.in
Sun Dec 21 12:57:51 EST 2003


Hi,

I have a main module which has few functions and in one of the functions, 
I have given an import statement so that I can get the functions and 
global variables present in other module into my main module's name space. 
The code is something like this

main.py

def f1():
	from sub import *

if __name__ == "__main__":
	f1()

But my problem is that the functions and other global variables present
sub are not getting imported to my main module. Can any body suggest me
what is the right method to do, the condition being that the import should
happen only if I call f1.

Thanks in advance,
Venkatesh

--------------------------------------------------------------------------
Venkatesh Babu K R,                          Residence
M.Tech,
Department of CSE,                           #B311, Hall 4,
IIT Kanpur                                   IIT Kanpur
e-mail: vbabu at cse.iitk.ac.in
website: www.cse.iitk.ac.in/users/vbabu
--------------------------------------------------------------------------




More information about the Tutor mailing list