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
85f928a5
Commit
85f928a5
authored
Apr 15, 2010
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add various items
parent
b3dde134
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
2 deletions
+48
-2
Doc/whatsnew/2.7.rst
Doc/whatsnew/2.7.rst
+48
-2
No files found.
Doc/whatsnew/2.7.rst
View file @
85f928a5
...
...
@@ -8,7 +8,7 @@
.. Fix accents on Kristjan Valur Jonsson, Fuerstenau
.. Big jobs:
argparse, ElementTree 1.3, pep 391, 3106
, sysconfig
.. Big jobs:
ElementTree 1.3, pep 391
, sysconfig
.. unittest test discovery
.. hyperlink all the methods & functions.
...
...
@@ -383,7 +383,48 @@ Two smaller enhancements to the logging module are:
PEP 3106: Dictionary Views
====================================================
XXX write this section.
The dictionary methods :meth:`keys`, :meth:`values`, and :meth:`items`
are different in Python 3.x. They return an object called a :dfn:`view`
instead of a fully materialized list.
.. Views can be iterated over, but they also behave like sets. XXX not working.
It's not possible to change the return values of :meth:`keys`,
:meth:`values`, and :meth:`items` in Python 2.7 because too much code
would break. Instead the 3.x versions were added under the new names
of :meth:`viewkeys`, :meth:`viewvalues`, and :meth:`viewitems`.
::
>>> d = dict((i*10, chr(65+i)) for i in range(26))
>>> d
{0: 'A', 130: 'N', 10: 'B', 140: 'O', 20: ..., 250: 'Z'}
>>> d.viewkeys()
dict_keys([0, 130, 10, 140, 20, 150, 30, ..., 250])
The view keeps track of the dictionary and its contents change as the
dictionary is modified::
>>> vk = d.viewkeys()
>>> vk
dict_keys([0, 130, 10, ..., 250])
>>> d[260] = '&'
>>> vk
dict_keys([0, 130, 260, 10, ..., 250])
However, note that you can't add or remove keys while you're iterating
over the view::
>>> for k in vk:
... d[k*2] = k
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: dictionary changed size during iteration
You can use the view methods in Python 2.x code, and the 2to3
converter will change them to the standard :meth:`keys`,
:meth:`values`, and :meth:`items` methods.
.. seealso::
...
...
@@ -1693,6 +1734,11 @@ Other Changes and Fixes
with a new :option:`-F` switch that runs selected tests in a loop
until they fail. (Added by Antoine Pitrou; :issue:`7312`.)
* When executed as a script, the :file:`py_compile.py` module now
accepts ``'-'`` as an argument, which will read standard input for
the list of filenames to be compiled. (Contributed by Piotr
Ożarowski; :issue:`8233`.)
.. ======================================================================
Porting to Python 2.7
...
...
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