collections.somenamedtuple._fields

somenamedtuple._fields Tuple of strings listing the field names. Useful for introspection and for creating new named tuple types from existing named tuples. >>> p._fields # view the field names ('x', 'y') >>> Color = namedtuple('Color', 'red green blue') >>> Pixel = namedtuple('Pixel', Point._fields + Color._fields) >>> Pixel(11, 22, 128, 255, 0) Pixel(x=11, y=22, red=128, green=255, blue=0)

collections.somenamedtuple._asdict()

somenamedtuple._asdict() Return a new OrderedDict which maps field names to their corresponding values: >>> p = Point(x=11, y=22) >>> p._asdict() OrderedDict([('x', 11), ('y', 22)]) Changed in version 3.1: Returns an OrderedDict instead of a regular dict.

collections.OrderedDict.popitem()

popitem(last=True) The popitem() method for ordered dictionaries returns and removes a (key, value) pair. The pairs are returned in LIFO order if last is true or FIFO order if false.

collections.OrderedDict.move_to_end()

move_to_end(key, last=True) Move an existing key to either end of an ordered dictionary. The item is moved to the right end if last is true (the default) or to the beginning if last is false. Raises KeyError if the key does not exist: >>> d = OrderedDict.fromkeys('abcde') >>> d.move_to_end('b') >>> ''.join(d.keys()) 'acdeb' >>> d.move_to_end('b', last=False) >>> ''.join(d.keys()) 'bacde' New in version 3.2.

collections.OrderedDict

class collections.OrderedDict([items]) Return an instance of a dict subclass, supporting the usual dict methods. An OrderedDict is a dict that remembers the order that keys were first inserted. If a new entry overwrites an existing entry, the original insertion position is left unchanged. Deleting an entry and reinserting it will move it to the end. New in version 3.1. popitem(last=True) The popitem() method for ordered dictionaries returns and removes a (key, value) pair. The pairs are

collections.namedtuple()

collections.namedtuple(typename, field_names, verbose=False, rename=False) Returns a new tuple subclass named typename. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have a helpful docstring (with typename and field_names) and a helpful __repr__() method which lists the tuple contents in a name=value format. The field_names are a single string with each fieldname se

collections.deque.rotate()

rotate(n) Rotate the deque n steps to the right. If n is negative, rotate to the left. Rotating one step to the right is equivalent to: d.appendleft(d.pop()).

collections.deque.reverse()

reverse() Reverse the elements of the deque in-place and then return None. New in version 3.2.

collections.deque.remove()

remove(value) Remove the first occurrence of value. If not found, raises a ValueError.

collections.deque.popleft()

popleft() Remove and return an element from the left side of the deque. If no elements are present, raises an IndexError.