I have a module blah.time
where I do some sanity checks and wrapper functions around normal time and date operations:
import time
def sleep(n):
time.sleep(n)
When I call sleep
, it just throws a maximum recursion error. I'm guessing the namespace is wrong, so I tried using import time as _time
, but I still get the same error.
How do I reference the system time
module from within my own module in order to prevent this namespace conflict?
Add from __future__ import absolute_import
as the first line in your file.
This will force all imports to be absolute rather then relative. So import time
will import the standard module, to import a local module you'd use from . import foobar
I would read http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports and then use from __future__ import absolute_import
.
HTH
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