dns :: set :: Set :: Class Set
[hide private]
[frames] | no frames]

Class Set

source code

object --+
         |
        Set
Known Subclasses:

A simple set class.

This class was originally used to deal with sets being missing in ancient versions of python, but dnspython will continue to use it as these sets are based on lists and are thus indexable, and this ability is widely used in dnspython applications.

Instance Methods [hide private]
 
__init__(self, items=None)
Initialize the set.
source code
 
__repr__(self)
repr(x)
source code
 
add(self, item)
Add an item to the set.
source code
 
remove(self, item)
Remove an item from the set.
source code
 
discard(self, item)
Remove an item from the set if present.
source code
 
_clone(self)
Make a (shallow) copy of the set.
source code
 
__copy__(self)
Make a (shallow) copy of the set.
source code
 
copy(self)
Make a (shallow) copy of the set.
source code
 
union_update(self, other)
Update the set, adding any elements from other which are not already in the set.
source code
 
intersection_update(self, other)
Update the set, removing any elements from other which are not in both sets.
source code
 
difference_update(self, other)
Update the set, removing any elements from other which are in the set.
source code
 
union(self, other)
Return a new set which is the union of ``self`` and ``other``.
source code
 
intersection(self, other)
Return a new set which is the intersection of ``self`` and ``other``.
source code
 
difference(self, other)
Return a new set which ``self`` - ``other``, i.e.
source code
 
__or__(self, other) source code
 
__and__(self, other) source code
 
__add__(self, other) source code
 
__sub__(self, other) source code
 
__ior__(self, other) source code
 
__iand__(self, other) source code
 
__iadd__(self, other) source code
 
__isub__(self, other) source code
 
update(self, other)
Update the set, adding any elements from other which are not already in the set.
source code
 
clear(self)
Make the set empty.
source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__len__(self) source code
 
__iter__(self) source code
 
__getitem__(self, i) source code
 
__delitem__(self, i) source code
 
issubset(self, other)
Is this set a subset of *other*?
source code
 
issuperset(self, other)
Is this set a superset of *other*?
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  items

Inherited from object: __class__

Method Details [hide private]

__init__(self, items=None)
(Constructor)

source code 

Initialize the set.

*items*, an iterable or ``None``, the initial set of items.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

_clone(self)

source code 

Make a (shallow) copy of the set.

There is a 'clone protocol' that subclasses of this class should use. To make a copy, first call your super's _clone() method, and use the object returned as the new instance. Then make shallow copies of the attributes defined in the subclass.

This protocol allows us to write the set algorithms that return new instances (e.g. union) once, and keep using them in subclasses.

union(self, other)

source code 

Return a new set which is the union of ``self`` and ``other``.

Returns the same Set type as this set.

intersection(self, other)

source code 

Return a new set which is the intersection of ``self`` and ``other``.

Returns the same Set type as this set.

difference(self, other)

source code 

Return a new set which ``self`` - ``other``, i.e. the items in ``self`` which are not also in ``other``.

Returns the same Set type as this set.

update(self, other)

source code 

Update the set, adding any elements from other which are not already in the set.

*other*, the collection of items with which to update the set, which may be any iterable type.

issubset(self, other)

source code 

Is this set a subset of *other*?

Returns a ``bool``.

issuperset(self, other)

source code 

Is this set a superset of *other*?

Returns a ``bool``.