Skip to content

Commit 437567c

Browse files
committed
Some edits; add empty sections
1 parent 9aa37ab commit 437567c

File tree

1 file changed

+68
-35
lines changed

1 file changed

+68
-35
lines changed

Doc/whatsnew/whatsnew25.tex

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,29 @@
1616
for Python 2.5 has been set; it will probably be released in the
1717
autumn of 2006.
1818

19-
% Compare with previous release in 2 - 3 sentences here.
19+
% XXX Compare with previous release in 2 - 3 sentences here.
2020

2121
This article doesn't attempt to provide a complete specification of
2222
the new features, but instead provides a convenient overview. For
2323
full details, you should refer to the documentation for Python 2.5.
24-
% add hyperlink when the documentation becomes available online.
24+
% XXX add hyperlink when the documentation becomes available online.
2525
If you want to understand the complete implementation and design
2626
rationale, refer to the PEP for a particular new feature.
2727

2828

29+
%======================================================================
30+
\section{PEP 308: Conditional Expressions}
31+
32+
% XXX write this
33+
34+
2935
%======================================================================
3036
\section{PEP 309: Partial Function Application}
3137

3238
The \module{functional} module is intended to contain tools for
33-
functional-style programming. Currently it only contains
34-
\class{partial}, but new functions will probably be added in future
35-
versions of Python.
39+
functional-style programming. Currently it only contains a
40+
\class{partial()} function, but new functions will probably be added
41+
in future versions of Python.
3642

3743
For programs written in a functional style, it can be useful to
3844
construct variants of existing functions that have some of the
@@ -59,6 +65,7 @@ \section{PEP 309: Partial Function Application}
5965
...
6066
6167
server_log = functional.partial(log, subsystem='server')
68+
server_log('Unable to open socket')
6269
\end{verbatim}
6370

6471
Here's another example, from a program that uses PyGTk. Here a
@@ -91,15 +98,15 @@ \section{PEP 309: Partial Function Application}
9198
\section{PEP 314: Metadata for Python Software Packages v1.1}
9299

93100
Some simple dependency support was added to Distutils. The
94-
\function{setup()} function now has \code{requires},\code{provides},
95-
and \code{obsoletes}. When you build a source distribution using the
96-
\code{sdist} command, the dependency information will be recorded in
97-
the \file{PKG-INFO} file.
101+
\function{setup()} function now has \code{requires}, \code{provides},
102+
and \code{obsoletes} keyword parameters. When you build a source
103+
distribution using the \code{sdist} command, the dependency
104+
information will be recorded in the \file{PKG-INFO} file.
98105

99-
Another new keyword is \code{download_url}, which should be set to a
100-
URL for the package's source code. This means it's now possible to
101-
look up an entry in the package index, determine the dependencies for
102-
a package, and download the required packages.
106+
Another new keyword parameter is \code{download_url}, which should be
107+
set to a URL for the package's source code. This means it's now
108+
possible to look up an entry in the package index, determine the
109+
dependencies for a package, and download the required packages.
103110

104111
% XXX put example here
105112

@@ -112,16 +119,28 @@ \section{PEP 314: Metadata for Python Software Packages v1.1}
112119
\end{seealso}
113120

114121

122+
%======================================================================
123+
\section{PEP 328: Absolute and Relative Imports}
124+
125+
% XXX write this
126+
127+
128+
%======================================================================
129+
\section{PEP 341: Unified try/except/finally}
130+
131+
% XXX write this
132+
133+
115134
%======================================================================
116135
\section{PEP 342: New Generator Features}
117136

118137
As introduced in Python 2.3, generators only produce output; once a
119-
generator's code was invoked to create an iterator, there's no way to
120-
pass new parameters into the function when its execution is resumed.
121-
Hackish solutions to this include making the generator's code look at
122-
a global variable and then changing the global variable's value, or
123-
passing in some mutable object that callers then modify. Python
124-
2.5 adds the ability to pass values \emph{into} a generator.
138+
generator's code is invoked to create an iterator, there's no way to
139+
pass any new information into the function when its execution is
140+
resumed. Hackish solutions to this include making the generator's
141+
code look at a global variable and then changing the global variable's
142+
value, or passing in some mutable object that callers then modify.
143+
Python 2.5 adds the ability to pass values \emph{into} a generator.
125144

126145
To refresh your memory of basic generators, here's a simple example:
127146

@@ -138,7 +157,7 @@ \section{PEP 342: New Generator Features}
138157
\keyword{yield} statement, the iterator returns the provided value and
139158
suspends the function's execution, preserving the local variables.
140159
Execution resumes on the following call to the iterator's
141-
\method{next()} method, picking up after the \keyword{yield}.
160+
\method{next()} method, picking up after the \keyword{yield} statement.
142161

143162
In Python 2.3, \keyword{yield} was a statement; it didn't return any
144163
value. In 2.5, \keyword{yield} is now an expression, returning a
@@ -152,17 +171,17 @@ \section{PEP 342: New Generator Features}
152171
expression when you're doing something with the returned value, as in
153172
the above example. The parentheses aren't always necessary, but it's
154173
easier to always add them instead of having to remember when they're
155-
needed. The exact rules are that a \keyword{yield}-expression must
174+
needed.\footnote{The exact rules are that a \keyword{yield}-expression must
156175
always be parenthesized except when it occurs at the top-level
157-
expression on the right-hand side of an assignment, meaning
158-
you can to write \code{val = yield i} but \code{val = (yield i) + 12}.
159-
% XXX ending of last para makes no sense
176+
expression on the right-hand side of an assignment, meaning you can
177+
write \code{val = yield i} but have to use parentheses when there's an
178+
operation, as in \code{val = (yield i) + 12}.}
160179

161180
Values are sent into a generator by calling its
162181
\method{send(\var{value})} method. The generator's code is then
163-
resumed and the \keyword{yield} expression produces \var{value}.
164-
If the regular \method{next()} method is called, the \keyword{yield}
165-
returns \constant{None}.
182+
resumed and the \keyword{yield} expression returns the specified
183+
\var{value}. If the regular \method{next()} method is called, the
184+
\keyword{yield} returns \constant{None}.
166185

167186
Here's the previous example, modified to allow changing the value of
168187
the internal counter.
@@ -198,12 +217,13 @@ \section{PEP 342: New Generator Features}
198217
StopIteration
199218
\end{verbatim}
200219

201-
Because \keyword{yield} will often be returning \constant{None},
202-
you shouldn't just use its value in expressions unless you're sure
203-
that only the \method{send()} method will be used.
220+
Because \keyword{yield} will often be returning \constant{None}, you
221+
should always check for this case. Don't just use its value in
222+
expressions unless you're sure that the \method{send()} method
223+
will be the only method used resume your generator function.
204224

205-
There are two other new methods on generators in addition to
206-
\method{send()}:
225+
In addition to \method{send()}, there are two other new methods on
226+
generators:
207227

208228
\begin{itemize}
209229

@@ -229,13 +249,14 @@ \section{PEP 342: New Generator Features}
229249

230250
The cumulative effect of these changes is to turn generators from
231251
one-way producers of information into both producers and consumers.
252+
232253
Generators also become \emph{coroutines}, a more generalized form of
233-
subroutines; subroutines are entered at one point and exited at
254+
subroutines. Subroutines are entered at one point and exited at
234255
another point (the top of the function, and a \keyword{return
235256
statement}), but coroutines can be entered, exited, and resumed at
236-
many different points (the \keyword{yield} statements).science term
257+
many different points (the \keyword{yield} statements).
258+
237259

238-
239260
\begin{seealso}
240261

241262
\seepep{342}{Coroutines via Enhanced Generators}{PEP written by
@@ -253,6 +274,18 @@ \section{PEP 342: New Generator Features}
253274
\end{seealso}
254275

255276

277+
%======================================================================
278+
\section{PEP 343: The 'with' statement}
279+
280+
% XXX write this
281+
282+
283+
%======================================================================
284+
\section{PEP 357: The '__index__' method}
285+
286+
% XXX write this
287+
288+
256289
%======================================================================
257290
\section{Other Language Changes}
258291

0 commit comments

Comments
 (0)