summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2007-03-01 14:36:12 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2007-03-01 14:36:12 (GMT)
commit7659a87e49cfde60817d556fcfdf62e4e97713cc (patch)
tree43f779ea22936b0281e0878ffae76eac72cd655b
parent052c371417a4892a6c6c0d3865d8a04e820821ef (diff)
downloadcpython-7659a87e49cfde60817d556fcfdf62e4e97713cc.zip
cpython-7659a87e49cfde60817d556fcfdf62e4e97713cc.tar.gz
cpython-7659a87e49cfde60817d556fcfdf62e4e97713cc.tar.bz2
Add NamedTuple
-rw-r--r--Doc/whatsnew/whatsnew26.tex16
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/whatsnew/whatsnew26.tex b/Doc/whatsnew/whatsnew26.tex
index fe0a6dd..d341155 100644
--- a/Doc/whatsnew/whatsnew26.tex
+++ b/Doc/whatsnew/whatsnew26.tex
@@ -76,6 +76,22 @@ details.
\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