Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes
collections.UserList Class Reference
Inheritance diagram for collections.UserList:
Inheritance graph
[legend]
Collaboration diagram for collections.UserList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __repr__
def __lt__
def __le__
def __eq__
def __ne__
def __gt__
def __ge__
def __contains__
def __len__
def __getitem__
def __setitem__
def __delitem__
def __add__
def __radd__
def __iadd__
def __mul__
def __imul__
def append
def insert
def pop
def remove
def count
def index
def reverse
def sort
def extend
def __iter__
def __reversed__
def index
def __subclasshook__
def __subclasshook__
def __subclasshook__
def __new__
def __new__
def __new__
def register
def register
def register
def __instancecheck__
def __instancecheck__
def __instancecheck__
def __subclasscheck__
def __subclasscheck__
def __subclasscheck__

Public Attributes

 data

Private Member Functions

def __cast

Static Private Attributes

 __rmul__ = __mul__

Detailed Description

A more or less complete user-defined wrapper around list objects.

Definition at line 833 of file collections.py.


Constructor & Destructor Documentation

def collections.UserList.__init__ (   self,
  initlist = None 
)

Definition at line 835 of file collections.py.

00835 
00836     def __init__(self, initlist=None):
00837         self.data = []
00838         if initlist is not None:
00839             # XXX should this accept an arbitrary sequence?
00840             if type(initlist) == type(self.data):
00841                 self.data[:] = initlist
00842             elif isinstance(initlist, UserList):
00843                 self.data[:] = initlist.data[:]
00844             else:
                self.data = list(initlist)

Here is the caller graph for this function:


Member Function Documentation

def collections.UserList.__add__ (   self,
  other 
)

Definition at line 859 of file collections.py.

00859 
00860     def __add__(self, other):
00861         if isinstance(other, UserList):
00862             return self.__class__(self.data + other.data)
00863         elif isinstance(other, type(self.data)):
00864             return self.__class__(self.data + other)
        return self.__class__(self.data + list(other))

Here is the caller graph for this function:

def collections.UserList.__cast (   self,
  other 
) [private]

Definition at line 852 of file collections.py.

00852 
00853     def __cast(self, other):
        return other.data if isinstance(other, UserList) else other

Here is the caller graph for this function:

def collections.UserList.__contains__ (   self,
  item 
)

Reimplemented from _abcoll.Sequence.

Definition at line 854 of file collections.py.

00854 
    def __contains__(self, item): return item in self.data
def collections.UserList.__delitem__ (   self,
  i 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 858 of file collections.py.

00858 
    def __delitem__(self, i): del self.data[i]
def collections.UserList.__eq__ (   self,
  other 
)

Definition at line 848 of file collections.py.

00848 
    def __eq__(self, other): return self.data == self.__cast(other)

Here is the call graph for this function:

Here is the caller graph for this function:

def collections.UserList.__ge__ (   self,
  other 
)

Definition at line 851 of file collections.py.

00851 
    def __ge__(self, other): return self.data >= self.__cast(other)

Here is the call graph for this function:

def collections.UserList.__getitem__ (   self,
  i 
)

Reimplemented from _abcoll.Sequence.

Definition at line 856 of file collections.py.

00856 
    def __getitem__(self, i): return self.data[i]

Here is the caller graph for this function:

def collections.UserList.__gt__ (   self,
  other 
)

Definition at line 850 of file collections.py.

00850 
    def __gt__(self, other): return self.data >  self.__cast(other)

Here is the call graph for this function:

def collections.UserList.__iadd__ (   self,
  other 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 871 of file collections.py.

00871 
00872     def __iadd__(self, other):
00873         if isinstance(other, UserList):
00874             self.data += other.data
00875         elif isinstance(other, type(self.data)):
00876             self.data += other
00877         else:
00878             self.data += list(other)
        return self
def collections.UserList.__imul__ (   self,
  n 
)

Definition at line 882 of file collections.py.

00882 
00883     def __imul__(self, n):
00884         self.data *= n
        return self
def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def _abcoll.Sequence.__iter__ (   self) [inherited]

Reimplemented from _abcoll.Iterable.

Definition at line 539 of file _abcoll.py.

00539 
00540     def __iter__(self):
00541         i = 0
00542         try:
00543             while True:
00544                 v = self[i]
00545                 yield v
00546                 i += 1
00547         except IndexError:
00548             return

def collections.UserList.__le__ (   self,
  other 
)

Definition at line 847 of file collections.py.

00847 
    def __le__(self, other): return self.data <= self.__cast(other)

Here is the call graph for this function:

Reimplemented from _abcoll.Sized.

Definition at line 855 of file collections.py.

00855 
    def __len__(self): return len(self.data)
def collections.UserList.__lt__ (   self,
  other 
)

Definition at line 846 of file collections.py.

00846 
    def __lt__(self, other): return self.data <  self.__cast(other)

Here is the call graph for this function:

def collections.UserList.__mul__ (   self,
  n 
)

Definition at line 879 of file collections.py.

00879 
00880     def __mul__(self, n):
        return self.__class__(self.data*n)
def collections.UserList.__ne__ (   self,
  other 
)

Definition at line 849 of file collections.py.

00849 
    def __ne__(self, other): return self.data != self.__cast(other)

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def collections.UserList.__radd__ (   self,
  other 
)

Definition at line 865 of file collections.py.

00865 
00866     def __radd__(self, other):
00867         if isinstance(other, UserList):
00868             return self.__class__(other.data + self.data)
00869         elif isinstance(other, type(self.data)):
00870             return self.__class__(other + self.data)
        return self.__class__(list(other) + self.data)

Definition at line 845 of file collections.py.

00845 
    def __repr__(self): return repr(self.data)
def _abcoll.Sequence.__reversed__ (   self) [inherited]

Definition at line 555 of file _abcoll.py.

00555 
00556     def __reversed__(self):
00557         for i in reversed(range(len(self))):
00558             yield self[i]

def collections.UserList.__setitem__ (   self,
  i,
  item 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 857 of file collections.py.

00857 
    def __setitem__(self, i, item): self.data[i] = item
def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def _abcoll.Iterable.__subclasshook__ (   cls,
  C 
) [inherited]

Reimplemented in _abcoll.Iterator.

Definition at line 74 of file _abcoll.py.

00074 
00075     def __subclasshook__(cls, C):
00076         if cls is Iterable:
00077             if any("__iter__" in B.__dict__ for B in C.__mro__):
00078                 return True
00079         return NotImplemented
00080 

Here is the call graph for this function:

def _abcoll.Sized.__subclasshook__ (   cls,
  C 
) [inherited]

Definition at line 119 of file _abcoll.py.

00119 
00120     def __subclasshook__(cls, C):
00121         if cls is Sized:
00122             if any("__len__" in B.__dict__ for B in C.__mro__):
00123                 return True
00124         return NotImplemented
00125 

Here is the call graph for this function:

def _abcoll.Container.__subclasshook__ (   cls,
  C 
) [inherited]

Definition at line 133 of file _abcoll.py.

00133 
00134     def __subclasshook__(cls, C):
00135         if cls is Container:
00136             if any("__contains__" in B.__dict__ for B in C.__mro__):
00137                 return True
00138         return NotImplemented
00139 

Here is the call graph for this function:

def collections.UserList.append (   self,
  item 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 885 of file collections.py.

00885 
    def append(self, item): self.data.append(item)

Here is the caller graph for this function:

def collections.UserList.count (   self,
  item 
)

Reimplemented from _abcoll.Sequence.

Definition at line 889 of file collections.py.

00889 
    def count(self, item): return self.data.count(item)
def collections.UserList.extend (   self,
  other 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 893 of file collections.py.

00893 
00894     def extend(self, other):
00895         if isinstance(other, UserList):
00896             self.data.extend(other.data)
00897         else:
00898             self.data.extend(other)
00899 
00900 

def _abcoll.Sequence.index (   self,
  value 
) [inherited]

Definition at line 559 of file _abcoll.py.

00559 
00560     def index(self, value):
00561         for i, v in enumerate(self):
00562             if v == value:
00563                 return i
00564         raise ValueError

Here is the call graph for this function:

Here is the caller graph for this function:

def collections.UserList.index (   self,
  item,
  args 
)

Definition at line 890 of file collections.py.

00890 
    def index(self, item, *args): return self.data.index(item, *args)

Here is the caller graph for this function:

def collections.UserList.insert (   self,
  i,
  item 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 886 of file collections.py.

00886 
    def insert(self, i, item): self.data.insert(i, item)

Here is the caller graph for this function:

def collections.UserList.pop (   self,
  i = -1 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 887 of file collections.py.

00887 
    def pop(self, i=-1): return self.data.pop(i)

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def collections.UserList.remove (   self,
  item 
)

Reimplemented from _abcoll.MutableSequence.

Definition at line 888 of file collections.py.

00888 
    def remove(self, item): self.data.remove(item)

Here is the caller graph for this function:

Reimplemented from _abcoll.MutableSequence.

Definition at line 891 of file collections.py.

00891 
    def reverse(self): self.data.reverse()
def collections.UserList.sort (   self,
  args,
  kwds 
)

Definition at line 892 of file collections.py.

00892 
    def sort(self, *args, **kwds): self.data.sort(*args, **kwds)

Member Data Documentation

Definition at line 881 of file collections.py.

Definition at line 836 of file collections.py.


The documentation for this class was generated from the following file: