On 6/13/12 8:33 PM, Christian Heimes wrote:
Am 13.06.2012 16:56, schrieb Christian Heimes:
Am 13.06.2012 13:41, schrieb Tarek Ziadé:
Hey

I was surprised not to find any way to list all protocol names listed in
/etc/protocols in Python

We have

socket.getprotobyname(NAME)

But there's no way to get the list of names

Any ideas if this is available in the stdlib somehwere ?
No, I can't find any reference to the relevant NSS APIs in the Python
code. You can easily roll your own with ctypes:
PS: You can also parse the output of "getent protocols". As for all name
services you shouldn't parse the file as other sources (ldap, dns, nis,
databases) can provide additional information. See man nsswitch.conf

Christian

Thanks for the pointers -- I was going to open('etc/protocols').readlines() :)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to