[Python-Dev] Package ambiguities
Gordon McMillan
gmcm@hypernet.com
Wed, 7 Jun 2000 19:47:47 -0400
Ka-Ping wrote:
> ... In short:
>
> from parent import * ... Parent doesn't work
> import parent ... parent.Parent doesn't work
>
> from A.parent import * ... Parent works
> import A.parent ... A.parent.Parent works
Right. That's why I cast relative imports as evil.
> This problem is an "advanced" version of a simpler issue
> which a friend of mine discovered and complained about
> recently to me: the __main__ vs. module-name conflict.
This comes up a whole lot. In those periods where I have the
time, energy and patience to monitor c.l.py closely, I've seen
this come up 4 or 5 times in one week. Almost always in
conjunction with import *.
I can live with explaining how __main__ is special. That's one
of those "you only have to explain it once" problems.
But the import * problems (name hiding, the fact that
assignments aren't seen) and relative imports are things that
come up over and over again, and trip up even experienced
people (and them more than once).
- Gordon