本文整理汇总了Python中netaddr.IPNetwork.__iter__方法的典型用法代码示例。如果您正苦于以下问题:Python IPNetwork.__iter__方法的具体用法?Python IPNetwork.__iter__怎么用?Python IPNetwork.__iter__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netaddr.IPNetwork
的用法示例。
在下文中一共展示了IPNetwork.__iter__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IPRoute
# 需要导入模块: from netaddr import IPNetwork [as 别名]
# 或者: from netaddr.IPNetwork import __iter__ [as 别名]
class IPRoute(object):
network=None
gateway=None
interface=None
name=None
def __init__(self, network, netmask, gateway, interface, name=None):
self.network=IPNetwork("%s/%s" % (network, netmask))
self.gateway=IPAddress(gateway)
self.interface=interface
self.name=name
def is_in(self,address):
return IPAddress(address) in IPNetwork
def __iter__(self):
return self.network.__iter__()
def __str__(self):
if self.name:
return "%s via %s on %s, called %s" % (self.network, self.gateway, self.interface, self.name)
else:
return "%s via %s on %s" % (self.network, self.gateway, self.interface)
def __repr__(self):
return "%s('%s')" % (self.__class__.__name__, self)
def get_name(self):
return self.name