Python 1.6 alpha 1 released
fredrik at pythonware.com
fredrik at pythonware.com
Wed Apr 5 07:54:15 EDT 2000
Toby Dickenson wrote:
> Does the single-argument connect require a 2-tuple, or just a two
> element sequence?
sure.
class WebServer:
def __init__(self, host, port=80):
self.address = host, port
def __len__(self):
return len(self.address)
def __getitem__(self, index):
return self.address[index]
import socket
host = WebServer("www.pythonware.com")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(host)
# ...
> If a sequence will do, then you can use an address class today.
exactly.
</F>
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list