New PEP: Quality Guidelines For Standard Modules

Skip Montanaro skip at pobox.com
Mon Jul 2 19:09:29 CEST 2001


    C//> This is inarguably and obviously bad design. The author's choice of
    C//> an implicit singleton in this case was a great error and lacked
    C//> even small amounts of foresight. The error here, however, was not
    C//> the global variable. It was the implicit global singleton attached
    C//> to contextually-dependent state.

Let's not be too hasty here.  Version 1.1 of fileinput.py is dated
21-Nov-97, well before threading was widespread in Python (which is where
this stray global stuff tends to really bite you in the butt, the original
author's example notwithstanding).  Also, until a year or so ago, the
fileinput module was not widely used, so any design problems it harbors were
likely to bite relatively few butts.  The original design probably worked
well for the original author.

The now deprecated regex module suffered from the same problem.  It was
heavily used for several years nonetheless before being replaced by two revs
of Perl-compatible regular expressions.

If the current implementation of the fileinput module creates problems for
you, rework it and submit a patch. ;-)

-- 
Skip Montanaro (skip at pobox.com)
(847)971-7098




More information about the Python-list mailing list