[Webware-discuss] Duplicate modules problem

Chuck Esterbrook echuck at mindspring.com
Thu Feb 22 22:12:11 EST 2001


At 10:05 PM 2/22/2001 -0500, Terrel Shumway wrote:
> > - Does anyone know why it would be bad for Python to track modules by
> > absolute path?
>
>It would make it more difficult to move modules around. (Java demonstrates
>this.)  Tool support would help: it is easy to search for import statements.

I don't follow that at all. This is strictly a run time phenomena. Who 
wants to move modules once the program starts?


> > - Is there any chance Python will fix this in the future?
>
>Hmmm.  Seems like it does not really need a fix from On High: only a
>widely-published HOWTO documenting the problem and the solution.

Well unless your previous comment pans out, there doesn't seem to be a 
reason to track them by relative path. And since doing so leads to 
problems, it seems that an On High fix would be more appropriate than 
considering the situation to be OK simply because it's documented.


Also, I'm not really sure if I want to replace '' in sys.path. I thought 
that was there as a relative path to the current module (not the current 
directory) and therefore helped a given file Foo.py say "import Bar from 
Bar" where Bar.py resided in the same package. Particularly if you didn't 
even import Foo directly.  Am I wrong about that?

As Geoff pointed out, we most likely encountered this problem because we're 
running a program out of a package, which is uncommon. I tried Geoff's fix 
on the example code I wrote and it worked like a charm. I'll try it on 
Webware next.

If the fix pans out for Webware, that will be great, but unless there is a 
concrete advantage to tracking packages by relative path, I still recommend 
a change in Python to track modules by absolute path. That would eliminate 
accidently getting 2 distinct copies of the same module for any Python program.


Thanks for the input,
-Chuck





More information about the Python-list mailing list