mirror of
https://github.com/python/cpython.git
synced 2025-11-03 19:34:08 +00:00
Issue #11141: Fix the shelve documentation to use a list, not a range object.
Patch by SilentGhost.
This commit is contained in:
parent
da397903c9
commit
631507d1c6
2 changed files with 3 additions and 2 deletions
|
|
@ -182,6 +182,7 @@ docs@python.org), and we'll be glad to correct the problem.
|
||||||
* Joakim Sernbrant
|
* Joakim Sernbrant
|
||||||
* Justin Sheehy
|
* Justin Sheehy
|
||||||
* Charlie Shepherd
|
* Charlie Shepherd
|
||||||
|
* SilentGhost
|
||||||
* Michael Simcich
|
* Michael Simcich
|
||||||
* Ionel Simionescu
|
* Ionel Simionescu
|
||||||
* Michael Sloan
|
* Michael Sloan
|
||||||
|
|
|
||||||
|
|
@ -169,8 +169,8 @@ object)::
|
||||||
klist = list(d.keys()) # a list of all existing keys (slow!)
|
klist = list(d.keys()) # a list of all existing keys (slow!)
|
||||||
|
|
||||||
# as d was opened WITHOUT writeback=True, beware:
|
# as d was opened WITHOUT writeback=True, beware:
|
||||||
d['xx'] = range(4) # this works as expected, but...
|
d['xx'] = [0, 1, 2] # this works as expected, but...
|
||||||
d['xx'].append(5) # *this doesn't!* -- d['xx'] is STILL range(4)!
|
d['xx'].append(3) # *this doesn't!* -- d['xx'] is STILL [0, 1, 2]!
|
||||||
|
|
||||||
# having opened d without writeback=True, you need to code carefully:
|
# having opened d without writeback=True, you need to code carefully:
|
||||||
temp = d['xx'] # extracts the copy
|
temp = d['xx'] # extracts the copy
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue