Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7a53a8ef
Commit
7a53a8ef
authored
May 10, 2002
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give the enumerate() PEP a section of its own
Add some credits Fill in a link
parent
36332a95
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
36 deletions
+50
-36
Doc/whatsnew/whatsnew23.tex
Doc/whatsnew/whatsnew23.tex
+50
-36
No files found.
Doc/whatsnew/whatsnew23.tex
View file @
7a53a8ef
...
...
@@ -215,9 +215,44 @@ and implemented by Jack Jansen.}
\end{seealso}
%======================================================================
\section
{
PEP 285: The
\class
{
bool
}
Type
\label
{
section-bool
}}
\section
{
PEP 279: The
\function
{
enumerate()
}
Built-in Function
}
A new built-in function,
\function
{
enumerate()
}
, will make
certain loops a bit clearer.
\code
{
enumerate(thing)
}
, where
\var
{
thing
}
is either an iterator or a sequence, returns a iterator
that will return
\code
{
(0,
\var
{
thing[0]
}
)
}
,
\code
{
(1,
\var
{
thing[1]
}
)
}
,
\code
{
(2,
\var
{
thing[2]
}
)
}
, and so forth. Fairly
often you'll see code to change every element of a list that looks
like this:
\begin{verbatim}
for i in range(len(L)):
item = L[i]
# ... compute some result based on item ...
L[i] = result
\end{verbatim}
This can be rewritten using
\function
{
enumerate()
}
as:
\begin{verbatim}
for i, item in enumerate(L):
# ... compute some result based on item ...
L[i] = result
\end{verbatim}
\begin{seealso}
\seepep
{
279
}{
The enumerate() built-in function
}{
Written
by Raymond D. Hettinger.
}
\end{seealso}
%======================================================================
\section
{
PEP 285: The
\class
{
bool
}
Type
\label
{
section-bool
}}
A Boolean type was added to Python 2.3. Two new constants were added
to the
\module
{__
builtin
__}
module,
\constant
{
True
}
and
...
...
@@ -292,41 +327,20 @@ strings \samp{True} and \samp{False} instead of \samp{1} and \samp{0}.
%======================================================================
\section
{
Other Language Changes
}
Here are the changes that Python 2.3 makes to the core language.
\begin{itemize}
\item
The
\keyword
{
yield
}
statement is now always a keyword, as
described in section~
\ref
{
section-generators
}
.
\item
Two new constants,
\constant
{
True
}
and
\constant
{
False
}
were
added along with the built-in
\class
{
bool
}
type, as described in
section~
\ref
{
section-bool
}
.
\item
A new built-in function,
\function
{
enumerate()
}
, will make
certain loops a bit clearer.
\code
{
enumerate(thing)
}
, where
\var
{
thing
}
is either an iterator or a sequence, returns a iterator
that will return
\code
{
(0,
\var
{
thing[0]
}
)
}
,
\code
{
(1,
\var
{
thing[1]
}
)
}
,
\code
{
(2,
\var
{
thing[2]
}
)
}
, and so forth. Fairly
often you'll see code to change every element of a list that looks like this:
%\section{Other Language Changes}
\begin{verbatim}
for i in range(len(L)):
item = L[i]
# ... compute some result based on item ...
L[i] = result
\end{verbatim}
%Here are the changes that Python 2.3 makes to the core language.
This can be rewritten using
\function
{
enumerate()
}
as:
%\begin{itemize}
%\item The \keyword{yield} statement is now always a keyword, as
%described in section~\ref{section-generators}.
\begin{verbatim}
for i, item in enumerate(L):
# ... compute some result based on item ...
L[i] = result
\end{verbatim}
%\item Two new constants, \constant{True} and \constant{False} were
%added along with the built-in \class{bool} type, as described in
%section~\ref{section-bool}.
\end{itemize}
%\item
%\end{itemize}
%======================================================================
...
...
@@ -386,7 +400,7 @@ support, turn on the Python interpreter's debugging code by running
\begin{seealso}
\seeurl
{
XXX
}
\seeurl
{
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Objects/obmalloc.c
}
{
For the full details of the pymalloc implementation, see
the comments at the top of the file
\file
{
Objects/obmalloc.c
}
in the
Python source code. The above link points to the file within the
...
...
@@ -491,7 +505,7 @@ packages for use on HP-UX. (Contributed by Mark Alexander.)
characters using the
\samp
{
u
}
format character. Arrays also
now support using the
\code
{
+=
}
assignment operator to add another array's
contents, and the
\code
{
*=
}
assignment operator to repeat an array.
(Contributed by
XXX
.)
(Contributed by
Jason Orendorff
.)
\item
The
\module
{
grp
}
module now returns enhanced tuples:
...
...
@@ -518,8 +532,8 @@ Changes to Python's build process, and to the C API, include:
\item
Python can now optionally be built as a shared library
(
\file
{
libpython2.3.so
}
) by supplying
\longprogramopt
{
enable-shared
}
when running Python's
\file
{
configure
}
script. (Contributed by
XXX
Pa
tch
\#
527027
)
when running Python's
\file
{
configure
}
script. (Contributed by
Ondrej
Pa
lkovsky.
)
\item
The
\cfunction
{
PyArg
_
NoArgs()
}
macro is now deprecated, and code
that
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment