How do I access a main frunction from an import module?
Anton Vredegoor
anton.vredegoor at gmail.com
Fri Nov 24 09:44:45 EST 2006
Jim wrote:
> I have created an import module. And would like to access a function
> from the main script, e.g.,
>
> file abc.py:
> ###################
> def a():
> m()
> return None
> ####################
>
> file main.py:
> #####################
> from abc import *
> def m():
> print 'something'
> return None
>
> a()
import sys
def a():
sys.modules['__main__'].m()
return None
Anton
'now why would anyone want to do *that* ?'
More information about the Python-list
mailing list