[Python-Dev] Optional arguments for str.encode /.decode
Raymond Hettinger
python at rcn.com
Sat Nov 8 09:29:28 EST 2003
> "Raymond Hettinger" <raymond.hettinger at verizon.net> writes:
>
> > Idea for the day: Let the str.encode/decode methods accept keyword
> > arguments to be forwarded to the underlying codec.
>
> -1. The non-Unicode usage of .encode should not have been there in the
> first place, IMO, so I dislike any extensions to it.
I understand a desire to keep it pure. Would it be useful to add a
separate method to support non-Unicode access? This style of access has
some wonderful properties in terms of decoupling, accessibility,
learnability, and uniformity. I can image that many kinds of bulk
string operations could benefit from this interface:
t.transform('crc32')
t.transform('md5')
t.transform('des_encode', key=0x10ab03b78495d2)
t.transform('substitution', name='guido', home='netherlands')
t.transform('huffman')
Raymond Hettinger
More information about the Python-Dev
mailing list