Package netaddr :: Module address :: Class Wildcard
[frames] | no frames]

Class Wildcard

source code

object --+    
         |    
 AddrRange --+
             |
            Wildcard

Represents a block of contiguous IPv4 network addresses defined using a wildcard/glob style syntax.

Individual octets can be represented using the following shortcuts :-

1) The asterisk '*' octet.

This represents the values 0 through 255.

2) The hyphenated octet 'x-y'

This represents a range of values between x and y.

x must always be greater than y, therefore :-

values of x are 0 through 254 values of y are 1 through 255

NB - only one hyphenated octet per wildcard is allowed.

Example wildcards :-

'192.168.0.1' # a single address '192.168.0.0-31' # 32 addresses '192.168.0.*' # 256 addresses '192.168.0-1.*' # 512 addresses '192.168-169.*.*' # 131,072 addresses '*.*.*.*' # the whole IPv4 address space

Aside: Wildcard ranges are not directly equivalent to CIDR ranges as they can represent address ranges that do not conform to bit mask boundaries. All CIDR ranges can be represented as wilcard ranges but the reverse isn't always true.

Instance Methods
 
__init__(self, wildcard, klass=<class 'netaddr.address.IP'>)
Constructor.
source code
 
is_wildcard(self, wildcard)
True if wildcard address is valid, False otherwise.
source code
 
__str__(self)
str(x)
source code

Inherited from AddrRange: __contains__, __eq__, __ge__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, first, last, size

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties

Inherited from object: __class__

Method Details

__init__(self, wildcard, klass=<class 'netaddr.address.IP'>)
(Constructor)

source code 

Constructor.

wildcard - a valid wildcard address (only IPv4 is supported).

klass - (optional) class used to create each return object. Default: IP objects. See nrange() documentations for additional details on options.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)