Skip to content Skip to sidebar Skip to footer

Python: Problem With Local Modules Shadowing Global Modules

I've got a package set up like so: packagename/ __init__.py numbers.py tools.py ...other stuff Now inside tools.py, I'm trying to import the standard library modul

Solution 1:

absolute and relative imports can be used since python2.5 (with __future__ import) and seem to be what you're looking for.

Solution 2:

I try to avoid shadowing the standard library. How about renaming your module to "_numbers.py" ?

And of course, you could still do:

import _numbers as numbers

Post a Comment for "Python: Problem With Local Modules Shadowing Global Modules"