A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/040061.html below:

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

[Python-Dev] Optional arguments for str.encode /.decode [Python-Dev] Optional arguments for str.encode /.decodeBarry Warsaw barry at python.org
Fri Nov 7 10:14:54 EST 2003
On Fri, 2003-11-07 at 10:06, Aahz wrote:

> Change this to
> 
>     def zlib_encode(input,errors='strict', opts=None):
>         if opts:
>             if 'level' in opts:
>                 ...
> 
> >>> 'which witch has which witches wristwatch'.encode('zlib', {'level':9})

Actually, I like that less.  It looks gross to me.  Keyword arguments
are a bit nicer, but do open the possibility for interference with
future arguments to .encode() and .decode().  I'm probably +0 with the
original and -0 with this style.

> and I'm +1.  Otherwise I'm somewhere around -0; I agree with Barry about
> possible pollution.  This change is a small inconvenience for greater
> decoupling.  opts could be an instance instead, but I think a straight
> dict probably makes the most sense.

Actually what I was complaining about probably is too late to "fix".  It
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. ;)

-Barry



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4