-
Notifications
You must be signed in to change notification settings - Fork 1
virttest.staging.backports.collections
- index
- modules |
- next |
- previous |
- Avocado VT 44.0 documentation »
- virttest »
- virttest package »
- virttest.staging package »
- virttest.staging.backports package »
virttest.staging.backports.collections package¶
Submodules¶
virttest.staging.backports.collections.OrderedDict module¶
Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy. Passes Python2.7’s test suite and incorporates all the latest updates.
Obtained from: http://code.activestate.com/recipes/576693-ordered-dictionary-for-py24/
classvirttest.staging.backports.collections.OrderedDict.``OrderedDict
(*args, **kwds)¶
Bases: dict
Dictionary that remembers insertion order
http://code.activestate.com/recipes/576693-ordered-dictionary-for-py24/ :codeauthor: Raymond Hettinger :license: MIT
Initialize an ordered dictionary.
Signature is the same as for regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary.
clear
() → None. Remove all items from od.¶
copy
() → a shallow copy of od¶
classmethodfromkeys
(S[, v]) → New ordered dictionary with keys from S¶
and values equal to v (which defaults to None).
items
() → list of (key, value) pairs in od¶
iteritems
()¶
od.iteritems -> an iterator over the (key, value) items in od
iterkeys
() → an iterator over the keys in od¶
itervalues
()¶
od.itervalues -> an iterator over the values in od
keys
() → list of keys in od¶
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
() → (k, v), return and remove a (key, value) pair.¶
Pairs are returned in LIFO order if last is true or FIFO order if false.
setdefault
(k[, d]) → od.get(k,d), also set od[k]=d if k not in od¶
update
(E, **F) → None. Update od from dict/iterable E and F.¶
If E is a dict instance, does: for k in E: od[k] = E[k] If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] Or if E is an iterable of items, does: for k, v in E: od[k] = v In either case, this is followed by: for k, v in F.items(): od[k] = v
values
() → list of values in od¶
viewitems
() → a set-like object providing a view on od's items¶
viewkeys
() → a set-like object providing a view on od's keys¶
viewvalues
() → an object providing a view on od's values¶
virttest.staging.backports.collections.defaultdict module¶
Backport of the defaultdict module, obtained from: http://code.activestate.com/recipes/523034-emulate-collectionsdefaultdict/
classvirttest.staging.backports.collections.defaultdict.``defaultdict
(default_factory=None, *a, **kw)¶
Bases: dict
collections.defaultdict is a handy shortcut added in Python 2.5 which can be emulated in older versions of Python. This recipe tries to backport defaultdict exactly and aims to be safe to subclass and extend without worrying if the base class is in C or is being emulated.
http://code.activestate.com/recipes/523034-emulate-collectionsdefaultdict/ :codeauthor: Jason Kirtland :license: PSF
Changes: * replaced self.items() with self.iteritems() to fix Pickle bug as recommended by Aaron Lav * reformated with autopep8
copy
()¶
virttest.staging.backports.collections.namedtuple module¶
This module contains a backport for collections.namedtuple obtained from http://code.activestate.com/recipes/500261-named-tuples/
virttest.staging.backports.collections.namedtuple.``namedtuple
(typename, field_names, verbose=False, rename=False)¶
Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', 'x y')
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional args or keywords
>>> p[0] + p[1] # indexable like a plain tuple
33
>>> x, y = p # unpack like a regular tuple
>>> x, y
(11, 22)
>>> p.x + p.y # fields also accessible by name
33
>>> d = p._asdict() # convert to a dictionary
>>> d['x']
11
>>> Point(**d) # convert from a dictionary
Point(x=11, y=22)
>>> p._replace(x=100) # _replace() is like str.replace() but targets named fields
Point(x=100, y=22)
http://code.activestate.com/recipes/500261-named-tuples/ :codeauthor: Raymond Hettinger :license: PSF
Changes: * autopep8 reformatting
Module contents¶
virttest.staging.backports package
virttest.staging.backports.simplejson package
- index
- modules |
- next |
- previous |
- Avocado VT 44.0 documentation »
- virttest »
- virttest package »
- virttest.staging package »
- virttest.staging.backports package »
© Copyright 2014, Red Hat. Created using Sphinx 1.5.1.