Local vs Global imports python -


i not seeing answer out there, apologies if duplicate. basically, trying understand how force interpreter (2.7) import module site packages if there conflict. example imagine running python directory (top_level) has following structure:

top_level ----cool_mod     ----init.py     ----sweet_module.py 

but have installed sweet module site packages. when in directory (but no others) if run:

from cool_mod.sweet_module import * 

you import local module, not global one. can change somehow?

this situation might arise case:

top_level  setup.py ----cool_mod     ----init.py     ----sweet_module.py 

you can run cool_mod.sweet_module before installing if working directory top_level. after installing can import cool_mod.sweet_module anywhere. however, if ever import directory, after installation, still import local copy

inserting site package directory @ begining of sys.path, , import.

or, use imp.load_source load module specified path.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -