Strange Behavior

Peter Otten __peter__ at web.de
Tue Jun 3 04:01:26 EDT 2014


Steven D'Aprano wrote:

> On Mon, 02 Jun 2014 20:05:29 +0200, robertw89 wrote:
> 
>> I invoked the wrong bug.py :/ , works fine now (this happens to me when
>> im a bit tired sometimes...).
> 
> Clarity in naming is an excellent thing. If you have two files called
> "bug.py", that's two too many.

In the case of the OP the code is likely to be thrown away once the bug is 
found. Putting all experiments into a single folder even with the overly 
generic name "bug" would have been "good enough" to avoid the problem.
 
> Imagine having fifty files called "program.py". Which one is which? How
> do you know? Programs should be named by what they do (think of Word,
> which does word processing, or Photoshop, which does photo editing), or
> when that isn't practical, at least give them a unique and memorable name
> (Outlook, Excel). The same applies to files demonstrating bugs.
 
Outlook and Excel are only good names because these are popular 
applications. If I were to name some private scripts in that style and not 
use them for a few months -- I don't think I'd have a clue what excel.py is 
meant to do. 

I have a few find_dupes dedupe_xxx compare_xxx scripts lying around and no 
idea which is which. So a reasonably clear name is not sufficient if there 
are other scripts that perform similar tasks.

One approach that seems to be working so far is to combine several scripts 
into one using argparse subparsers. This results in more frequent usage 
which means I can get away with short meaningless names, and infrequent 
actions are just one

$ xx -h

away.




More information about the Python-list mailing list