[Python-Dev] other "magic strings" issues

Alex Martelli aleaxit at yahoo.com
Fri Nov 7 12:37:27 EST 2003

On Friday 07 November 2003 06:05 pm, Guido van Rossum wrote:
> Doesn't seem the right solution to me.  If I were to design an API
> for this without reference to the C convention, I'd probably use
> keyword arguments.

Interesting!  Something like f = file('foo', writable=True) ... ?

> I outright disagree with Brunning's idea for the struct module.  More
> verbose isn't always more readable or easier to remember.

Heh, yes, I didn't even quote that one, being -1 on it myself:-)

> > Another separate "attributes of types" issue raised by that same
> > blog entry -- and that one does find me +1 -- is: isn't it time to
> > make available as attributes of the str type object those few things
> > that we still need to 'import string' for?  E.g., the maketrans
> > function (and maybe we could even give it a better name as long as
> > we're making it a str.something?)...
> Yes, that would be good.  Is there anything besides maketrans() in the
> string module worth saving?  (IMO letters and digits etc. are not --
> you can use s.isletter() etc. for that.)

Hmmm, I do have loops such as 'for c in string.ascii_lowercase: ..."; e.g
in a letter-counting example:

for c in string.ascii_lowercase:
    print '%s: %8d" % (c, counts.get(c,0))

using counts.keys(), sorted, wouldn't be the same, as the 0's would not
stand out.  Admittedly coding 'abc...xyz' explicitly ain't gonna kill me, 


More information about the Python-Dev mailing list