Back to index

python3.2  3.2.2
Classes | Functions | Variables
reprlib Namespace Reference

Classes

class  Repr

Functions

def recursive_repr
def _possibly_sorted

Variables

list __all__ = ["Repr", "repr", "recursive_repr"]
tuple aRepr = Repr()
 repr = aRepr.repr

Detailed Description

Redo the builtin repr() (representation) but with limits on most sizes.

Function Documentation

def reprlib._possibly_sorted (   x) [private]

Definition at line 147 of file reprlib.py.

00147 
00148 def _possibly_sorted(x):
00149     # Since not all sequences of items can be sorted and comparison
00150     # functions may raise arbitrary exceptions, return an unsorted
00151     # sequence in that case.
00152     try:
00153         return sorted(x)
00154     except Exception:
00155         return list(x)

Here is the call graph for this function:

Here is the caller graph for this function:

def reprlib.recursive_repr (   fillvalue = '...')

Definition at line 12 of file reprlib.py.

00012 
00013 def recursive_repr(fillvalue='...'):
00014     'Decorator to make a repr function return fillvalue for a recursive call'
00015 
00016     def decorating_function(user_function):
00017         repr_running = set()
00018 
00019         def wrapper(self):
00020             key = id(self), get_ident()
00021             if key in repr_running:
00022                 return fillvalue
00023             repr_running.add(key)
00024             try:
00025                 result = user_function(self)
00026             finally:
00027                 repr_running.discard(key)
00028             return result
00029 
00030         # Can't use functools.wraps() here because of bootstrap issues
00031         wrapper.__module__ = getattr(user_function, '__module__')
00032         wrapper.__doc__ = getattr(user_function, '__doc__')
00033         wrapper.__name__ = getattr(user_function, '__name__')
00034         wrapper.__annotations__ = getattr(user_function, '__annotations__', {})
00035         return wrapper
00036 
00037     return decorating_function

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

list reprlib.__all__ = ["Repr", "repr", "recursive_repr"]

Definition at line 3 of file reprlib.py.

tuple reprlib.aRepr = Repr()

Definition at line 156 of file reprlib.py.

reprlib.repr = aRepr.repr

Definition at line 157 of file reprlib.py.