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

Class Wildcard

source code

object --+    
         |    
 AddrRange --+
             |
            Wildcard

A block of contiguous IPv4 network addresses defined using a wildcard style syntax.

Individual octets can be represented using the following shortcuts :

  1. * - the asterisk octet (represents values 0 through 255)
  2. 'x-y' - the hyphenated octet (represents values x through y)

A few basic rules also apply :

  1. x must always be greater than y, therefore :
  2. only one hyphenated octet per wildcard is allowed
  3. only asterisks are permitted after a hyphenated octet

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 fall on strict bit mask boundaries.

All CIDR ranges can be represented as wildcard ranges but the reverse isn't always true.

Instance Methods
 
__init__(self, wildcard, klass=<class 'netaddr.address.IP'>)
Constructor.
source code
 
cidr(self)
Returns: A valid CIDR object for this wildcard.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
Returns: An executable Python statement that can recreate an object with an equivalent state.
source code

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

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

Properties

Inherited from object: __class__

Method Details

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

source code 

Constructor.

Parameters:
  • wildcard - a valid IPv4 wildcard address
  • klass - (optional) class used to create each return object. Default: IP objects. See nrange() documentations for additional details on options.
Overrides: object.__init__

cidr(self)

source code 
Returns:
A valid CIDR object for this wildcard. If conversion fails an AddrConversionError is raised as not all wildcards ranges are valid CIDR ranges.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Returns:
An executable Python statement that can recreate an object with an equivalent state.
Overrides: object.__repr__