Movatterモバイル変換
[0]ホーム
how to import from variable source
Martin Blessm.bless at gmx.de
Sun Apr 15 09:00:25 EDT 2001
>Use the __import__() builtin function:>>module = __import__('mymod')Is there a way to manipulate the resulting 'mymod.__name__'?If - against normal behavior - it could be set to '__main__' theimported 'mymod' could be deceived leading to execution of codein the common commonif __name__ == '__main__': pass # do somethingclause.Martin
More information about the Python-listmailing list
[8]ページ先頭