[Python-checkins] r54061 - python/trunk/Doc/whatsnew/whatsnew26.tex
andrew.kuchling
python-checkins at python.org
Thu Mar 1 15:36:13 CET 2007
Author: andrew.kuchling
Date: Thu Mar 1 15:36:12 2007
New Revision: 54061
Modified:
python/trunk/Doc/whatsnew/whatsnew26.tex
Log:
Add NamedTuple
Modified: python/trunk/Doc/whatsnew/whatsnew26.tex
==============================================================================
--- python/trunk/Doc/whatsnew/whatsnew26.tex (original)
+++ python/trunk/Doc/whatsnew/whatsnew26.tex Thu Mar 1 15:36:12 2007
@@ -76,6 +76,22 @@
\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:
\function{merge(iter1, iter2, ...)}
takes any number of iterables that return data
More information about the Python-checkins
mailing list