[New-bugs-announce] [issue8881] socket.getaddrinfo() should return named tuples

Giampaolo Rodola' report at bugs.python.org
Wed Jun 2 23:31:28 CEST 2010


New submission from Giampaolo Rodola' <g.rodola at gmail.com>:

As of right now socket.getaddrinfo() returns a sequence of 5-tuples reflecting family, type, protocol, canonname, and address of a socket:

>>> socket.getaddrinfo(None, 0)
[(10, 1, 6, '', ('::1', 0, 0, 0)), (10, 2, 17, '', ('::1', 0, 0, 0)), (10, 3, 0, '', ('::1', 0, 0, 0)), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 3, 0, '', ('127.0.0.1', 0))]

For readability it would be good if they were named tuples instead:

>>> socket.getaddrinfo(None, 0)[0]
addr_info(family=10, type=1, protocol=6, canonname='', address=('::1', 0, 0, 0))

Optionally, integers can be replaced by socket constant names:

>>> socket.getaddrinfo(None, 0)[0]
addr_info(family=socket.AF_INET6, type=socket.SOCK_STREAM, protocol=socket.IPPROTO_TCP, canonname='', address=('::1', 0, 0, 0))

----------
components: Library (Lib)
messages: 106916
nosy: exarkun, giampaolo.rodola, pitrou
priority: normal
severity: normal
status: open
title: socket.getaddrinfo() should return named tuples
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8881>
_______________________________________


More information about the New-bugs-announce mailing list