How to guard against bugs like this one?

Steve Holden steve at
Wed Feb 3 04:53:44 CET 2010

kj wrote:
> (For reasons I don't understand Stephen Hansen's posts don't show
> in my news server.  I became aware of his reply from a passing
> reference in one of Terry Reedy's post.  Then I found Hansen's post
> online, and then an earlier one, and pasted the relevant portion
> below.)
>> First, I don't shadow built in modules. Its really not very hard to avoid.
> ...*if* you happen to be clairvoyant.  I still don't see how the rest of us
> could have followed this fine principle in the case of
> prior to Python 2.6.
Clearly the more you know about the standard library the less likely
this is to be a problem. Had you been migrqating from an earlier version
 the breakage would have alerted you to look for some version-dependent

>> Secondly, I use packages structuring my libraries, and avoid junk
>> directories of a hundred some odd 'scripts'.
> <small>(I feel so icky now...)</small>
Be as flippant as you like, but that is good advice.

>> Third, I don't execute scripts in that directory structure directly, but
>> instead do python -c 'from package.blah import main; main.main()' or some
>> such. Usually via some short-cut, or a runner batch file.
> Breathtaking...  I wonder why the Python documentation, in particular
> the official Python tutorial, is not more forthcoming with these
> rules.
Because despite the fact that this issue has clearly bitten you badly
enough to sour you against the language, such issues are remarkably rare
in practice and normally rather easier to debug.

Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010
Holden Web LLC       

More information about the Python-list mailing list