En Mon, 01 Jun 2009 21:40:26 -0300, Steven D'Aprano <st...@remove-this-cybersource.com.au> escribió:

I have a package which includes a module which shadows a module in the
standard library. For example:

package
+-- __init__.py
+-- ham.py
+-- spam.py
+-- sys.py

Inside that package, I want to import the standard library sys. In other
words, I want an absolute import. [...]
What can I do in Python 2.4 to get an absolute import?

sys = __import__("sys", {})

The import statement uses the global namespace to determine which package it is called on; if you pass an empty namespace, it cannot infer package information.

Anyway, the best move would be to rename the offending module...

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to