| |
- dictfromlist(l)
- create a dictionary from a list like in perl.
parameters:
l -- the list. Note that the list must have an
even number of elements.
- dictmap(func, mydict)
- like map works on a list, this works on values of a dict.
- dictpic(keys, mydict)
- pick a list of keys from a dict and return a dict.
parameters:
keys -- a list of wanted keys
mydict -- the dictionary
returns:
the dictionary which contains only the keys
from the keys parameter.
exceptions:
may raise a KeyError exception if a key is not found
- flatten(l, ltypes=(<type 'list'>, <type 'tuple'>))
- flattens nested lists or tuples or a mix of both.
parameters:
l -- nested list or tuple structure
ltypes -- the subtypes for which flattening is performed.
- l_prefix_suffix_join(prefix, suffix, join, l, typecheck=True)
- enclose list element with prefix and suffix and do ljoin.
parameters:
prefix -- the prefix-element to put before each list-element
suffix -- the suffix-element to put after each list-element
join -- the infix-element to put between each two list-elements
l -- the list
typecheck -- Do a very simple typecheck. when True, the
prefix-, the suffix and the join-element must be of the
same type as the first element of the list.
The default is True.
- ljoin(var, l, typecheck=True)
- like join("") works for strings, this works for a list l.
parameters:
var -- the separator-element to put between list-elements
l -- the list
typecheck -- Do a very simple typecheck. when True, the
separator-element must be of the same
type as the first element of the list.
The default is True.
- lprefix(var, l, typecheck=True)
- prepend a prefix element to each list element.
parameters:
var -- the prefix-element to put before each list-element
l -- the list
typecheck -- Do a very simple typecheck. when True, the
prefix-element must be of the same
type as the first element of the list.
The default is True.
- lprefixsuffix(prefix, suffix, l, typecheck=True)
- put a prefix and a suffix around each list element.
parameters:
prefix -- the prefix-element to put before each list-element
suffix -- the suffix-element to put after each list-element
l -- the list
typecheck -- Do a very simple typecheck. when True, the
prefix- and the suffix-element must be of the
same type as the first element of the list.
The default is True.
- lsuffix(var, l, typecheck=True)
- append a suffix element to each list element.
parameters:
var -- the suffix-element to put after each list-element
l -- the list
typecheck -- Do a very simple typecheck. when True, the
suffix-element must be of the same
type as the first element of the list.
The default is True.
- lzip(a, b)
- merges two lists into a single one in like a zipper.
parameters:
a -- the first list
b -- the second list
- qm(expr, val1, val2)
- like question-mark ('?') operator in c or perl.
parameters:
expr -- the boolean expression that is tested
val1 -- the value that is returned when <expr>
is True
val2 -- the value that is returned when <expr>
is False
|