Python 1.6 alpha 1 released

Terry Reedy tjreedy at udel.edu
Sun Apr 2 22:32:14 EDT 2000


Guido is quoted as writing:

> """where you used to write sock.connect(host, port) you must now write
> sock.connect((host, port))"""

Since the de facto standard has been to use two parameters, I find this
change baffling.

Evidence of claim: the first two Python books ...
1. Internet Programming with Python by Watters, *van Rossum*, and Ahlstrom.
    p335:    s.connect(machine, port) # api definition, middle of page
    p342:    sock.connect(self.machine, self.port) # connect() method of
class GETRequest
2. Programming Python, Mark Lutz.
    p728:    s.connect(HOST, PORT) # sockclient.py
(Note: these are the only three uses I found in the two books.  The
GETRequest class, with its now-declared-to-be-an-error, is used in several
examples in the following pages.)
3. my memory impression of every other usage of connect that I have read
(I've never had cause yet to use it)

Additional reasons for opinion.
1. Adding the extra pair of parens is extra work for no gain.
2. The result strikes me as visually ugly.
Without countervailing philosophical justification, this code-breaking
change strikes me as contrary to both the spirit and practice of python.

The confusion-elimination reason for the list.append(item) API does not
apply here.

Is there any arguement (other than whatever the reference states) for
tuple-bundling the params of connect() that would not apply to every other
library function?

If the connect() code currently also accepts the new form, then the API
could be tightened just as well by eliminating the one-tuple variant.   How
much code would that break?

Terry J. Reedy





More information about the Python-list mailing list