Hi,
if I have:
/lib/foo.py
/lib/foo.mpy
&
sys.path=['/lib']
Which module has precedence?
What if:
/lib/foo.py
/libmpy/foo.mpy
&
sys.path=['/libmpy','/lib']
What happens here?
Thanks!
Precedence of .mpy & .py
Re: Precedence of .mpy & .py
Given the statement: "import foo"
The implementation is:
I'm fairly sure the answer is therefore "foo.py" in the first case, and "/libmpy/foo.mpy" in the second case. But this is pretty easy to confirm for yourself -- see viewtopic.php?f=2&t=7350&p=42007
The implementation is:
Code: Select all
for each dir in sys.path:
try foo/ (i.e "foo" is a package)
try foo.py
try foo.mpy
Re: Precedence of .mpy & .py
Thanks - your explanation and the linked thread helped me understand it!