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
2ec177f1
Commit
2ec177f1
authored
May 02, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Many minor markup adjustments for consistency.
parent
86d97634
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Doc/whatsnew/whatsnew22.tex
Doc/whatsnew/whatsnew22.tex
+10
-10
No files found.
Doc/whatsnew/whatsnew22.tex
View file @
2ec177f1
...
...
@@ -521,9 +521,9 @@ Python classes can define an \method{__iter__()} method, which should
create and return a new iterator for the object; if the object is its
own iterator, this method can just return
\code
{
self
}
. In particular,
iterators will usually be their own iterators. Extension types
implemented in C can implement a
\
code
{
tp
_
iter
}
function in order to
implemented in C can implement a
\
member
{
tp
_
iter
}
function in order to
return an iterator, and extension types that want to behave as
iterators can define a
\
code
{
tp
_
iternext
}
function.
iterators can define a
\
member
{
tp
_
iternext
}
function.
So, after all this, what do iterators actually do? They have one
required method,
\method
{
next()
}
, which takes no arguments and returns
...
...
@@ -552,7 +552,7 @@ In 2.2, Python's \keyword{for} statement no longer expects a sequence;
it expects something for which
\function
{
iter()
}
will return an iterator.
For backward compatibility and convenience, an iterator is
automatically constructed for sequences that don't implement
\method
{__
iter
__
()
}
or a
\
code
{
tp
_
iter
}
slot, so
\code
{
for i in
\method
{__
iter
__
()
}
or a
\
member
{
tp
_
iter
}
slot, so
\code
{
for i in
[1,2,3]
}
will still work. Wherever the Python interpreter loops over
a sequence, it's been changed to use the iterator protocol. This
means you can do things like this:
...
...
@@ -659,11 +659,11 @@ outputs the value of \code{i}, similar to a \keyword{return}
statement. The big difference between
\keyword
{
yield
}
and a
\keyword
{
return
}
statement is that on reaching a
\keyword
{
yield
}
the
generator's state of execution is suspended and local variables are
preserved. On the next call to the generator's
\code
{
.
next()
}
method,
preserved. On the next call to the generator's
\code
{
next()
}
method,
the function will resume executing immediately after the
\keyword
{
yield
}
statement. (For complicated reasons, the
\keyword
{
yield
}
statement isn't allowed inside the
\keyword
{
try
}
block
of a
\
code
{
try...
finally
}
statement; read
\pep
{
255
}
for a full
of a
\
keyword
{
try
}
...
\keyword
{
finally
}
statement; read
\pep
{
255
}
for a full
explanation of the interaction between
\keyword
{
yield
}
and
exceptions.)
...
...
@@ -863,7 +863,7 @@ of \code{/} will not change until Python 3.0.
\item
Classes can define methods called
\method
{__
truediv
__}
and
\method
{__
floordiv
__}
to overload the two division operators. At the
C level, there are also slots in the
\c
od
e
{
PyNumberMethods
}
structure
C level, there are also slots in the
\c
typ
e
{
PyNumberMethods
}
structure
so extension types can define the two operators.
\item
Python 2.2 supports some command-line arguments for testing
...
...
@@ -1131,7 +1131,7 @@ more information about XML-RPC.
function
\function
{
help()
}
that uses the
\module
{
pydoc
}
module
introduced in Python 2.1 to provide interactive help.
\code
{
help(
\var
{
object
}
)
}
displays any available help text about
\var
{
object
}
.
\
code
{
help()
}
with no argument puts you in an online
\var
{
object
}
.
\
function
{
help()
}
with no argument puts you in an online
help utility, where you can enter the names of functions, classes,
or modules to read their help text.
(Contributed by Guido van Rossum, using Ka-Ping Yee's
\module
{
pydoc
}
module.)
...
...
@@ -1243,7 +1243,7 @@ affect you very much.
\cfunction
{
PyArg
_
UnpackTuple()
}
, has been added that's simpler and
presumably faster. Instead of specifying a format string, the
caller simply gives the minimum and maximum number of arguments
expected, and a set of pointers to
\c
od
e
{
PyObject*
}
variables that
expected, and a set of pointers to
\c
typ
e
{
PyObject*
}
variables that
will be filled in with argument values.
\item
Two new flags
\constant
{
METH
_
NOARGS
}
and
\constant
{
METH
_
O
}
are
...
...
@@ -1358,10 +1358,10 @@ to experiment with these modules can uncomment them manually.
now convert it to an MBCS encoded string, as used by the Microsoft
file APIs. As MBCS is explicitly used by the file APIs, Python's
choice of ASCII as the default encoding turns out to be an
annoyance. On
Unix
, the locale's character set is used if
annoyance. On
\UNIX
, the locale's character set is used if
\function
{
locale.nl
_
langinfo(CODESET)
}
is available. (Windows
support was contributed by Mark Hammond with assistance from
Marc-Andr
\'
e Lemburg.
Unix
support was added by Martin von L
\"
owis.)
Marc-Andr
\'
e Lemburg.
\UNIX
{}
support was added by Martin von L
\"
owis.)
\item
Large file support is now enabled on Windows. (Contributed by
Tim Peters.)
...
...
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