[Python-Dev] Heads up: socket.connect() breakage ahead
Barry A. Warsaw
bwarsaw@cnri.reston.va.us
Fri, 24 Mar 2000 16:21:54 -0500 (EST)
>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:
GvR> Someone noticed that socket.connect() and a few related
GvR> functions (connect_ex() and bind()) take either a single
GvR> (host, port) tuple or two separate arguments, but that only
GvR> the tuple is documented.
GvR> Similar to append(), I'd like to close this gap, and I've
GvR> made the necessary changes. This will probably break lots of
GvR> code.
I don't agree that socket.connect() and friends need this fix. Yes,
obviously append() needed fixing because of the application of Tim's
Twelfth Enlightenment to the semantic ambiguity. But socket.connect()
has no such ambiguity; you may spell it differently, but you know
exactly what you mean.
My suggestion would be to not break any code, but extend connect's
interface to allow an optional second argument. Thus all of these
calls would be legal:
sock.connect(addr)
sock.connect(addr, port)
sock.connect((addr, port))
One nit on the documentation of the socket module. The second entry
says:
bind (address)
Bind the socket to address. The socket must not already be
bound. (The format of address depends on the address family --
see above.)
Huh? What "above" part should I see? Note that I'm reading this doc
off the web!
-Barry