I have the following directory structure
main_code.py
libs/
    __init__.py
    mylib.py
    time.py
with main_code.py just importing mylib:
from libs import mylib
and mylib.py just importing time:
import time
print time
Now it turns out that mylib.py imports libs/time.py and not the built-in standard library time. Is there any way to get the 'normal' behavior, i.e. that mylib.py imports the built-in standard library time, without changing time.py? Is this the 'normal' behavior anyway? Do I have to rename time.py? Are there any style guide recommendations more than PEP8 on that issue?
Add at the top of mylib.py:
from __future__ import absolute_import
See Rationale for Absolute Imports.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With