[py-dev] Local import
Joan Miller
peloko45 at gmail.com
Wed Dec 23 18:49:04 CET 2009
2009/12/23 holger krekel <holger at merlinux.eu>:
> thanks, i see. I think you could as well just do it once in a conftest.py file
> and avoid the dynamic discovery. The Python import system caches imports so all
> subsequent modules importing "scripy" would pick up the previously imported one.
You've reason; it works well from conftest.py file. Now I changed it
to avoid the discovery:
------------------
def import_local(source='lib'):
"""Inserts local library on 'sys.path'."""
current_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(os.path.dirname(current_dir), source))
------------------
More information about the py-dev
mailing list