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
0fc8351f
Commit
0fc8351f
authored
Feb 06, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the old UserDict module.
parent
f80680d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
82 deletions
+1
-82
Lib/UserDict.py
Lib/UserDict.py
+0
-81
Misc/NEWS
Misc/NEWS
+1
-1
No files found.
Lib/UserDict.py
deleted
100644 → 0
View file @
f80680d8
"""A more or less complete user-defined wrapper around dictionary objects."""
class
UserDict
:
def
__init__
(
self
,
dict
=
None
,
**
kwargs
):
self
.
data
=
{}
if
dict
is
not
None
:
self
.
update
(
dict
)
if
len
(
kwargs
):
self
.
update
(
kwargs
)
def
__repr__
(
self
):
return
repr
(
self
.
data
)
def
__eq__
(
self
,
dict
):
if
isinstance
(
dict
,
UserDict
):
return
self
.
data
==
dict
.
data
else
:
return
self
.
data
==
dict
def
__ne__
(
self
,
dict
):
if
isinstance
(
dict
,
UserDict
):
return
self
.
data
!=
dict
.
data
else
:
return
self
.
data
!=
dict
def
__len__
(
self
):
return
len
(
self
.
data
)
def
__getitem__
(
self
,
key
):
if
key
in
self
.
data
:
return
self
.
data
[
key
]
if
hasattr
(
self
.
__class__
,
"__missing__"
):
return
self
.
__class__
.
__missing__
(
self
,
key
)
raise
KeyError
(
key
)
def
__setitem__
(
self
,
key
,
item
):
self
.
data
[
key
]
=
item
def
__delitem__
(
self
,
key
):
del
self
.
data
[
key
]
def
clear
(
self
):
self
.
data
.
clear
()
def
copy
(
self
):
if
self
.
__class__
is
UserDict
:
return
UserDict
(
self
.
data
.
copy
())
import
copy
data
=
self
.
data
try
:
self
.
data
=
{}
c
=
copy
.
copy
(
self
)
finally
:
self
.
data
=
data
c
.
update
(
self
)
return
c
def
keys
(
self
):
return
self
.
data
.
keys
()
def
items
(
self
):
return
self
.
data
.
items
()
def
values
(
self
):
return
self
.
data
.
values
()
def
update
(
self
,
dict
=
None
,
**
kwargs
):
if
dict
is
None
:
pass
elif
isinstance
(
dict
,
UserDict
):
self
.
data
.
update
(
dict
.
data
)
elif
isinstance
(
dict
,
type
({}))
or
not
hasattr
(
dict
,
'items'
):
self
.
data
.
update
(
dict
)
else
:
for
k
,
v
in
dict
.
items
():
self
[
k
]
=
v
if
len
(
kwargs
):
self
.
data
.
update
(
kwargs
)
def
get
(
self
,
key
,
failobj
=
None
):
if
key
not
in
self
:
return
failobj
return
self
[
key
]
def
setdefault
(
self
,
key
,
failobj
=
None
):
if
key
not
in
self
:
self
[
key
]
=
failobj
return
self
[
key
]
def
pop
(
self
,
key
,
*
args
):
return
self
.
data
.
pop
(
key
,
*
args
)
def
popitem
(
self
):
return
self
.
data
.
popitem
()
def
__contains__
(
self
,
key
):
return
key
in
self
.
data
@
classmethod
def
fromkeys
(
cls
,
iterable
,
value
=
None
):
d
=
cls
()
for
key
in
iterable
:
d
[
key
]
=
value
return
d
class
IterableUserDict
(
UserDict
):
def
__iter__
(
self
):
return
iter
(
self
.
data
)
Misc/NEWS
View file @
0fc8351f
...
...
@@ -75,7 +75,7 @@ Library
- Created new UserDict class in collections module. This one inherits from and
complies with the MutableMapping ABC.
XXX still need to
covert old UserDict based tests and eliminate the old UserDict module.
XXX still need to
move docs
- Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping.
...
...
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