How to write Inline Functions in Python?

Peter Hansen peter at engcorp.com
Thu Nov 14 10:25:33 EST 2002


Arivazhagan wrote:
> 
> Hi Tim
> 
> I assume you're coming from C++. - Thats true.
> 
> Hi
> 
> My requirements here.
> 
> we have three python files names a.py, b.py and c.py.
> In a.py we are calling a global function in c.py which creates objects
> of a class in c.py depending on the parameters passed. These objects
> are created in the scope of c.py. But i need to happen in a.py without
> using the module name.
> so I thought that if we inline the function call so that it expands we
> can access that object without referring to the module name.
> 
> Is it possible? Is there some other methods to achieve this in python?

Certainly there is, but you haven't explained clearly enough what you
really want.  It sounds like you could simply be returning those objects
from a function defined in c.py and called from a.py.

My guess is you are mucking around with global variables at module 
scope level and getting yourself into a lot of trouble.

Can you explain *why* you need to refer to objects defined in another
module without referring to that module's name?  Or can you explain
why these objects are being created as globals instead of just 
returning them from a function?

-Peter



More information about the Python-list mailing list