[Tutor] Importing global variables and classes from other modules
Venkatesh Babu
vbabu at cse.iitk.ac.in
Mon Dec 22 11:11:05 EST 2003
On Sun, 21 Dec 2003, Danny Yoo wrote:
>
> > 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.
>
> Wait, wait. Doing a conditional import might be a very bad idea from a
> debugging standpoint.
>
> Can you show us why you want to import this way? That context might help
> us to suggest better alternatives, if there are any.
Hi Danny,
My program will be creating classes dynamically and I wish to save those
class definitions into the file and retrive these definitions at some
other point in time. I first thought of a simple strategy of storing the
class definition in file as a string and later executing the string so
that the class is created. But the class gets created inside the function
in which i call exec and its scope is confined to that function, so I
thought of using import instead of executing the string.
Can u suggest any other strategy for my problem.
Thank you,
Venkatesh
>
>
> Good luck to you!
>
--------------------------------------------------------------------------
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