How to import a standard library instead of the module of the same name in the module path

I have the following directory structure

main_code.py
libs/
    __init__.py
    mylib.py
    time.py

with main_code.pyjust import mylib:

from libs import mylib

and mylib.pyjust import time:

import time
print time

Now it turns out that it mylib.pyimports libs/time.py, not the built-in standard library time. Is there a way to get "normal" behavior, i.e. What mylib.pyimports the built-in standard library timewithout changing time.py? Is this generally "normal" behavior? Do I need to rename time.py? Are there more style guidelines than PEP8 on this issue?

+5
source share
1 answer

mylib.py:

from __future__ import absolute_import

. .

+6

All Articles