How to write Inline Functions in Python?

Arivazhagan arivu at qmaxtest.com
Fri Nov 15 08:01:48 EST 2002


Hi
We are extending python to develop a Board Description language for
ATE. say in our project there are 2 modules named a.py( provided by us
) and b.py.(the end user programs.)

In a.py
-------

import sys


class Good :
    def __init__(self, name ) :
        self.__name = name


def createGood( *names ) :
    for name in names :
       thisGood = Good( name )

#The following is done so that the objects created here can be
#accessed#from b.py without using the module name. 
#We just want to avoid this.
       sys.modules['__main__'].__dict__[name] = thisGood
   

In b.py
-------
from a import *

createGood( 'A', 'B', 'C' )

#We want to access like this without that additional codes. 
print A
print B
print C

regards
b.arivazhagan



More information about the Python-list mailing list