[Tutor] reference to main module
Luiz Siqueira Neto
cybersamurai at terra.com.br
Thu Dec 11 08:25:40 EST 2003
I discovery the answer, take a look:
import sys
main = sys.modules['__main__']
# now I can call some function on the fly
# Ex:
def test():
print 'yessss'
def testStart(funct):
getattrib(funct)()
# Example using it
testStart('test')
--------------------------------------------------------------------
This make me create a lot of functions by demand and use
polimorphism to call some function using some parameter
------------------ Now you can understand :) --------------------
>>> If you know another way please tell me. <<<
Magnus Lycka wrote:
>Luiz Siqueira Neto wrote:
>
>
>>How can I make a reference to main module to use getattr( main,
>>'function') on the fly?
>>
>>
>
>I don't think anyone quite understood your question.
>Can you tell us what you are trying to achieve?
>
>What do you mean by "main module"?
>
>
>
More information about the Tutor
mailing list