Commit 7659a87e authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

Add NamedTuple

parent 052c3714
...@@ -76,6 +76,22 @@ details. ...@@ -76,6 +76,22 @@ details.
\begin{itemize} \begin{itemize}
\item New data type in the \module{collections} module:
\class{NamedTuple(\var{typename}, \var{fieldnames})} is a factory function that
creates subclasses of the standard tuple whose fields are accessible
by name as well as index. For example:
\begin{verbatim}
var_type = collections.NamedTuple('variable',
'id name type size')
var = var_type(1, 'frequency', 'int', 4)
print var[0], var.id # Equivalent
print var[2], var.type # Equivalent
\end{verbatim}
(Contributed by Raymond Hettinger.)
\item New function in the \module{heapq} module: \item New function in the \module{heapq} module:
\function{merge(iter1, iter2, ...)} \function{merge(iter1, iter2, ...)}
takes any number of iterables that return data takes any number of iterables that return data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment