Module Conflicts
Steve Holden
steve at holdenweb.com
Thu Apr 10 18:22:52 EDT 2008
Terry Reedy wrote:
> "Jose" <jfgomez21 at gmail.com> wrote in message
> news:b7ed8b5e-91fa-4495-b4e3-4912be9e8d90 at s50g2000hsb.googlegroups.com...
> | On Apr 9, 10:36 pm, Benjamin <musiccomposit... at gmail.com> wrote:
> | > On Apr 9, 5:33 pm, Jose <jfgome... at gmail.com> wrote:
> | >
> | > > I have a module named math.py in a package with some class
> | > > definitions. I am trying to import the standard python math module
> | > > inside of math.py but It seems to be importing itself. Is there any
> | > > way around this problem without renaming my math.py file?
> | >
> | > Not without some unpythonic magic. It's really not good style to name
> | > a module the same as a stdlib one. It'll also confuse people reading
> | > your code.
> |
> | Yeah but I thought since math.py was in a package, it would be okay.
>
> The stdlib contains a few packages, but it is not a package in itself.
> So math is not in a package.
>
>
>
Indeed, the fact that there is a math.py indicates that it is a module:
a package would have been math/__init__.py.
For extra marks, what does the interpreter do with "import x" when there
is both an x.py and an x/__init__.py in the same directry on the path?
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list