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

# Class Set

source code

    object --+
             |
            Set

Known Subclasses:
  - rdataset.Rdataset

A simple set class.

Sets are not in Python until 2.3, and rdata are not immutable so we cannot use sets.Set anyway. This class implements subset of the 2.3 Set interface using a list as the container.

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
the same type as self |
union(self, other) Return a new set which is the union of self and other. | source code
the same type as self |
intersection(self, other) Return a new set which is the intersection of self and other. | source code
the same type as self |
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
__getslice__(self, i, j) | source code
__delslice__(self, i, j) | source code
bool |
issubset(self, other) Is self a subset of other? | source code
bool |
issuperset(self, other) Is self a superset of other? | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Instance Variables | [hide private]
list | items A list of the items which are in the set

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, items=None) (Constructor) | source code
Initialize the set. Parameters: `items` (any 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_update(self, other) | source code
Update the set, adding any elements from other which are not already in the set. Parameters: `other` (Set object) - the collection of items with which to update the set

### intersection_update(self, other) | source code
Update the set, removing any elements from other which are not in both sets. Parameters: `other` (Set object) - the collection of items with which to update the set

### difference_update(self, other) | source code
Update the set, removing any elements from other which are in the set. Parameters: `other` (Set object) - the collection of items with which to update the set

### union(self, other) | source code
Return a new set which is the union of self and other. Parameters: `other` (Set object) - the other set Returns: the same type as self

### intersection(self, other) | source code
Return a new set which is the intersection of self and other. Parameters: `other` (Set object) - the other set Returns: the same type as self

### difference(self, other) | source code
Return a new set which self - other, i.e. the items in self which are not also in other. Parameters: `other` (Set object) - the other set Returns: the same type as self

### update(self, other) | source code
Update the set, adding any elements from other which are not already in the set. Parameters: `other` (any iterable type) - the collection of items with which to update the set