[Python-Dev] Optional arguments for str.encode /.decode

Alex Martelli aleaxit at yahoo.com
Fri Nov 7 10:24:23 EST 2003

On Friday 07 November 2003 04:14 pm, Barry Warsaw wrote:
> Actually what I was complaining about probably is too late to "fix".  It

We must keep supporting that approach, yes (alas), but maybe it's
not too late to encourage another alternative style instead?  E.g., have
some object exposing attributes corresponding to those strings that
do name codecs, so that while e.g.

    s.encode('zlib', level=9)

would have to keep working, the officially encouraged style would be:

    s.encode(codec.zlib, level=9)

or something of that ilk...?

> was the use of a string for the first argument to .encode() and
> .decode().  I dislike that for the same reason we don't do
> obj.__dict__['attribute'] on a regular basis. ;)

So my suggestion would take us back to obj.attribute style (as a
preferred alternative to using 'attribute' overtly as a dict key)...


More information about the Python-Dev mailing list