From 2ff7148d092547e9573c9136e44a38bc4593e133 Mon Sep 17 00:00:00 2001 From: bildzeitung Date: Mon, 14 May 2018 14:31:56 -0400 Subject: Update docs s/ucollections/collections/g --- docs/library/collections.rst | 57 +++++++++++++++++++++++++++++++++++++++++++ docs/library/index.rst | 2 +- docs/library/ucollections.rst | 57 ------------------------------------------- 3 files changed, 58 insertions(+), 58 deletions(-) create mode 100644 docs/library/collections.rst delete mode 100644 docs/library/ucollections.rst (limited to 'docs/library') diff --git a/docs/library/collections.rst b/docs/library/collections.rst new file mode 100644 index 000000000..849e8b694 --- /dev/null +++ b/docs/library/collections.rst @@ -0,0 +1,57 @@ +:mod:`collections` -- collection and container types +===================================================== + +.. include:: ../templates/unsupported_in_circuitpython.inc + +.. module:: collections + :synopsis: collection and container types + +|see_cpython_module| :mod:`cpython:collections`. + +This module implements advanced collection and container types to +hold/accumulate various objects. + +Classes +------- + +.. function:: namedtuple(name, fields) + + This is factory function to create a new namedtuple type with a specific + name and set of fields. A namedtuple is a subclass of tuple which allows + to access its fields not just by numeric index, but also with an attribute + access syntax using symbolic field names. Fields is a sequence of strings + specifying field names. For compatibility with CPython it can also be a + a string with space-separated field named (but this is less efficient). + Example of use:: + + from collections import namedtuple + + MyTuple = namedtuple("MyTuple", ("id", "name")) + t1 = MyTuple(1, "foo") + t2 = MyTuple(2, "bar") + print(t1.name) + assert t2.name == t2[1] + +.. function:: OrderedDict(...) + + ``dict`` type subclass which remembers and preserves the order of keys + added. When ordered dict is iterated over, keys/items are returned in + the order they were added:: + + from collections import OrderedDict + + # To make benefit of ordered keys, OrderedDict should be initialized + # from sequence of (key, value) pairs. + d = OrderedDict([("z", 1), ("a", 2)]) + # More items can be added as usual + d["w"] = 5 + d["b"] = 3 + for k, v in d.items(): + print(k, v) + + Output:: + + z 1 + a 2 + w 5 + b 3 diff --git a/docs/library/index.rst b/docs/library/index.rst index 466068640..c7b6879aa 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -21,7 +21,7 @@ Python standard libraries and micro-libraries gc.rst sys.rst binascii.rst - ucollections.rst + collections.rst uerrno.rst hashlib.rst uheapq.rst diff --git a/docs/library/ucollections.rst b/docs/library/ucollections.rst deleted file mode 100644 index 396ba3c87..000000000 --- a/docs/library/ucollections.rst +++ /dev/null @@ -1,57 +0,0 @@ -:mod:`ucollections` -- collection and container types -===================================================== - -.. include:: ../templates/unsupported_in_circuitpython.inc - -.. module:: ucollections - :synopsis: collection and container types - -|see_cpython_module| :mod:`cpython:collections`. - -This module implements advanced collection and container types to -hold/accumulate various objects. - -Classes -------- - -.. function:: namedtuple(name, fields) - - This is factory function to create a new namedtuple type with a specific - name and set of fields. A namedtuple is a subclass of tuple which allows - to access its fields not just by numeric index, but also with an attribute - access syntax using symbolic field names. Fields is a sequence of strings - specifying field names. For compatibility with CPython it can also be a - a string with space-separated field named (but this is less efficient). - Example of use:: - - from ucollections import namedtuple - - MyTuple = namedtuple("MyTuple", ("id", "name")) - t1 = MyTuple(1, "foo") - t2 = MyTuple(2, "bar") - print(t1.name) - assert t2.name == t2[1] - -.. function:: OrderedDict(...) - - ``dict`` type subclass which remembers and preserves the order of keys - added. When ordered dict is iterated over, keys/items are returned in - the order they were added:: - - from ucollections import OrderedDict - - # To make benefit of ordered keys, OrderedDict should be initialized - # from sequence of (key, value) pairs. - d = OrderedDict([("z", 1), ("a", 2)]) - # More items can be added as usual - d["w"] = 5 - d["b"] = 3 - for k, v in d.items(): - print(k, v) - - Output:: - - z 1 - a 2 - w 5 - b 3 -- cgit v1.2.3