Split function for host:port in standard lib

Manuel Ebert maebert at uos.de
Tue Aug 26 08:10:10 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

AFAIK port names cannot contain any colons, so python2.5's  
'host:port' .rsplit(':') should do the job. On < 2.5 you probably  
need to do something like
s = addr.rindex(':')
host, port = addr[:s], addr[s+1:]

Best,
Manuel


On Aug 26, 2008, at 1:31 PM, Michael Ströder wrote:

> HI!
>
> Is there a function in the standard lib which can be used to split  
> a string containg 'host:port' into a tuple (host,port) and also  
> does this reliably for IPv6 addresses?
>
> Ciao, Michael.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iD8DBQFIs/KjcZ70OCIgLecRAlfpAJ9aTgw5sADVKHXHTahzE+4zyuTZhACghNi6
eYyGqdIl8ONJxznwJYZ78Cc=
=s8rW
-----END PGP SIGNATURE-----



More information about the Python-list mailing list