[Twisted-Python] Reliable way to check if Twisted has IPv6 support?

Amit Saha asaha at redhat.com
Thu Dec 12 20:22:50 MST 2013


Hello,

I have a code path similar to:

if Twisted has IPv6:
  # do this
else:
  # do that

I came up with this: 

Using 'getattr' to get a function which wouldn't exist if there was no IPv6 address as follows:

>>> from twisted.internet import abstract
>>> getattr(abstract, 'isIPv6Address')
<function isIPv6Address at 0x171a488>

Is there a more reliable way (which works with the Twisted-8.0+) to check this?

Thanks,
Amit.


-- 
Amit Saha <http://echorand.me>



More information about the Twisted-Python mailing list