@header@
 
 
matplotlib.cbook
index
/usr/local/lib/python2.3/site-packages/matplotlib/cbook.py

A collection of utility functions and classes.  Many (but not all)
from the Python Cookbook -- hence the name cbook

 
Modules
       
StringIO
errno
os
re
sys
traceback

 
Classes
       
Bunch
Null
RingBuffer
Sorter
__builtin__.dict(__builtin__.object)
Xlator
__builtin__.list(__builtin__.object)
silent_list

 
class Bunch
    Often we want to just collect a bunch of stuff together, naming each
item of the bunch; a dictionary's OK for that, but a small do- nothing
class is even handier, and prettier to use.  Whenever you want to
group a few variables:
 
  >>> point = Bunch(datum=2, squared=4, coord=12)
  >>> point.datum
 
  By: Alex Martelli
  From: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308
 
  Methods defined here:
__init__(self, **kwds)

 
class Null
    Null objects always and reliably "do nothing."
 
  Methods defined here:
__call__(self, *args, **kwargs)
__delattr__(self, name)
__getattr__(self, name)
__init__(self, *args, **kwargs)
__nonzero__(self)
__repr__(self)
__setattr__(self, name, value)
__str__(self)

 
class RingBuffer
    class that implements a not-yet-full buffer
 
  Methods defined here:
__get_item__(self, i)
__init__(self, size_max)
append(self, x)
append an element at the end of the buffer
get(self)
Return a list of elements from the oldest to the newest.

 
class Sorter
    Sort by attribute or item
 
Example usage:
sort = Sorter()
 
list = [(1, 2), (4, 8), (0, 3)]
dict = [{'a': 3, 'b': 4}, {'a': 5, 'b': 2}, {'a': 0, 'b': 0},
{'a': 9, 'b': 9}]
 
 
sort(list)       # default sort
sort(list, 1)    # sort by index 1
sort(dict, 'a')  # sort a list of dicts by key 'a'
 
  Methods defined here:
__call__ = byItem(self, data, itemindex=None, inplace=1)
byAttribute(self, data, attributename, inplace=1)
byItem(self, data, itemindex=None, inplace=1)
sort = byItem(self, data, itemindex=None, inplace=1)

 
class Xlator(__builtin__.dict)
    All-in-one multiple-string-substitution class
 
Example usage:
 
text = "Larry Wall is the creator of Perl"
adict = {
"Larry Wall" : "Guido van Rossum",
"creator" : "Benevolent Dictator for Life",
"Perl" : "Python",
}
 
print multiple_replace(adict, text)
 
xlat = Xlator(adict)
print xlat.xlat(text)
 
 
Method resolution order:
Xlator
__builtin__.dict
__builtin__.object

Methods defined here:
__call__(self, match)
Handler invoked for each regex match
xlat(self, text)
Translate text, returns the modified text.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Xlator' objects>
list of weak references to the object (if defined)

Methods inherited from __builtin__.dict:
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
x.__contains__(y) <==> y in x
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
clear(...)
D.clear() -> None.  Remove all items from D.
copy(...)
D.copy() -> a shallow copy of D
get(...)
D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
has_key(...)
D.has_key(k) -> True if D has a key k, else False
items(...)
D.items() -> list of D's (key, value) pairs, as 2-tuples
iteritems(...)
D.iteritems() -> an iterator over the (key, value) items of D
iterkeys(...)
D.iterkeys() -> an iterator over the keys of D
itervalues(...)
D.itervalues() -> an iterator over the values of D
keys(...)
D.keys() -> list of D's keys
pop(...)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
popitem(...)
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(...)
D.update(E) -> None.  Update D from E: for k in E.keys(): D[k] = E[k]
values(...)
D.values() -> list of D's values

Data and other attributes inherited from __builtin__.dict:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T
fromkeys = <built-in method fromkeys of type object>
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.

 
class silent_list(__builtin__.list)
    override repr when returning a list of matplotlib artists to
prevent long, meaningless output.  This is meant to be used for a
homogeneous list of a give type
 
 
Method resolution order:
silent_list
__builtin__.list
__builtin__.object

Methods defined here:
__init__(self, type, seq=None)
__repr__(self)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'silent_list' objects>
list of weak references to the object (if defined)

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
append(...)
L.append(object) -- append object to end
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
insert(...)
L.insert(index, object) -- insert object before index
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
remove(...)
L.remove(value) -- remove first occurrence of value
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
Functions
       
allequal(seq)
return true if all elements of seq compare equal.  If seq is 0 or
1 length, return True
allpairs(x)
return all possible pairs in sequence x
 
Condensed by Alex Martelli from this thread on c.l.python
http://groups.google.com/groups?q=all+pairs+group:*python*&hl=en&lr=&ie=UTF-8&selm=mailman.4028.1096403649.5135.python-list%40python.org&rnum=1
alltrue(seq)
dict_delall(d, keys)
delete all of the keys from the dict d
enumerate(seq)
# until 2.3
exception_to_str(s=None)
flatten(seq, scalarp=<function is_scalar>)
this generator flattens nested containers such as
 
>>> l=( ('John', 'Hunter'), (1,23), [[[[42,(5,23)]]]])
 
so that
 
>>> for i in flatten(l): print i,
John Hunter 1 23 42 5 23
 
By: Composite of Holger Krekel and Luther Blissett
From: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294
and Recipe 1.12 in cookbook
get_recursive_filelist(args)
Recurs all the files and dirs in args ignoring symbolic links and
return the files as a list of strings
get_split_ind(seq, N)
seq is a list of words.  Return the index into seq such that
len(' '.join(seq[:ind])<=N
is_file_like(obj)
is_scalar(obj)
is_string_like(obj)
iterable(obj)
listFiles(root, patterns='*', recurse=1, return_folders=0)
Recursively list files
from Parmar and Martelli in the Python Cookbook
mkdirs(newdir, mode=511)
onetrue(seq)
pieces(seq, num=2)
Break up the seq into num tuples
popd(d, *args)
Should behave like python2.3 pop method; d is a dict
 
# returns value for key and deletes item; raises a KeyError if key
# is not in dict
val = popd(d, key)
 
# returns value for key if key exists, else default.  Delete key,
# val item if it exists.  Will not raise a KeyError
val = popd(d, key, default)
soundex(name, len=4)
soundex module conforming to Odell-Russell algorithm
strip_math(s)
remove latex formatting from mathtext
unique(x)
Return a list of unique elements of x
wrap(prefix, text, cols)

 
Data
        False = False
True = True
generators = _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 4096)
major = 2
minor1 = 3
minor2 = 3
s = 'final'
tmp = 0
@footer@