[Python-Dev] other "magic strings" issues
aleaxit at yahoo.com
Fri Nov 7 11:08:02 EST 2003
From Barry's discussion of the problem of "magic strings" as arguments to
.encode / .decode , I was reminded of a blog entry,
which mentions another case of "magic strings" that might perhaps be
(optionally but suggestedly) changed into more-readable attributes (in
this case, clearly attributes of the 'file' type): mode arguments to 'file'
calls. Simon Brunning, the author of that blog entry, argues that
myFile = file(filename, 'rb')
(while of course we're going to keep accepting it forever) is not quite as
readable and maintainable as, e.g.:
myFile = file(filename, file.READ + file.BINARY)
Just curious -- what are everybody's feelings about that idea? I'm
about +0 on it, myself -- I doubt I'd remember to use it (too much C
in my past...:-) but I see why others would prefer it.
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?)...
More information about the Python-Dev