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
75d92c18
Commit
75d92c18
authored
Apr 02, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a __delitem__ to the Message class.
(Still no __setitem__, until I get a request to add it!)
parent
58b2bfd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
Lib/rfc822.py
Lib/rfc822.py
+22
-0
No files found.
Lib/rfc822.py
View file @
75d92c18
...
...
@@ -284,6 +284,28 @@ class Message:
"""Get a specific header, as from a dictionary."""
return
self
.
dict
[
string
.
lower
(
name
)]
def
__delitem__
(
self
,
name
):
"""Delete all occurrences of a specific header, if it is present."""
name
=
string
.
lower
(
name
)
if
not
self
.
dict
.
has_key
(
name
):
return
del
self
.
dict
[
name
]
name
=
name
+
':'
n
=
len
(
name
)
list
=
[]
hit
=
0
for
i
in
range
(
len
(
self
.
headers
)):
line
=
self
.
headers
[
i
]
if
string
.
lower
(
line
[:
n
])
==
name
:
hit
=
1
elif
line
[:
1
]
not
in
string
.
whitespace
:
hit
=
0
if
hit
:
list
.
append
(
i
)
list
.
reverse
()
for
i
in
list
:
del
self
.
headers
[
i
]
def
has_key
(
self
,
name
):
"""Determine whether a message contains the named header."""
return
self
.
dict
.
has_key
(
string
.
lower
(
name
))
...
...
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