0

how to import foo module like this example.

main.py :

import time
from foo import main
return main()

foo.py :

def main()
    print 'hello', time.time()

I tried to explain, there are two or more files, I wanted to upload a import already defined by another file without defining in what will be loaded, like my example

1 Answers1

0

Unfortunately that's not how Python works. Names must be available in the scope in which they are used. There is a scope that is always accessible, but modifying it is generally frowned upon since it makes code harder to read and use.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358