How to guard against bugs like this one?

Ethan Furman ethan at stoneleaf.us
Fri Feb 5 16:48:22 EST 2010


John Nagle wrote:
> kj wrote:
> ...
>>
>> Through a *lot* of trial an error I finally discovered that the
>> root cause of the problem was the fact that, in the same directory
>> as buggy.py, there is *another* innocuous little script, totally
>> unrelated, whose name happens to be numbers.py. 
> 
>    The right answer to this is to make module search return an
> error if two modules satisfy the search criteria.  "First find"
> isn't a good solution.
> 
>                 John Nagle

Then what happens when you *want* to shadow a module?  As MRAB suggests, 
if you are really concerned about it use a script that checks for 
duplicate modules (not a bad idea for debugging), but don't start 
throwing errors... next thing you know we won't be able to shadow 
classes, functions, or built-ins!  !-)

~Ethan~



More information about the Python-list mailing list