How to guard against bugs like this one?

Carl Banks pavlovevidence at gmail.com
Mon Feb 1 23:01:11 EST 2010


On Feb 1, 6:34 pm, kj <no.em... at please.post> wrote:
> Both scripts live in a directory filled with *hundreds* little
> one-off scripts like the two of them.  I'll call this directory
> myscripts in what follows.

[snip]

> How can the average Python programmer guard against this sort of
> time-devouring bug in the future (while remaining a Python programmer)?


Don't put hundreds of little one-off scripts in single directory.
Python can't save you from polluting your own namespace.

Don't choose such generic names for modules.  Keep in mind module
names are potentially globally visible and any sane advice you ever
heard about globals is to use descriptive names.  I instinctively use
adjectives, compound words, and abstract nouns for the names of all my
modules so as to be more descriptive, and to avoid name conflicts with
classes and variables.

Also learn to debug better.


Carl Banks



More information about the Python-list mailing list