How to write Inline Functions in Python?

David Brown david at no.westcontrol.spam.com
Thu Nov 14 12:02:24 EST 2002


"Arivazhagan" <arivu at qmaxtest.com> wrote in message
news:c8476101.0211140642.29540b96 at posting.google.com...
> 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?
>
> regards
> b.arivazhagan
>

Are you thinking of something like:

# c.py
class A :
    pass

def giveMeAnA(x) :
    a = A()
    a.x = x
    return a


# a.py
import c
a1 = c.giveMeAnA(1)
print a1.x











More information about the Python-list mailing list