summaryrefslogtreecommitdiff
path: root/Doc/includes/email-headers.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-02-25 18:14:09 +0200
committerBerker Peksag <berker.peksag@gmail.com>2015-02-25 18:14:09 +0200
commitf9e3cf1f9f6eaefba19593783e1cdf7681d1fa65 (patch)
treecbaa625efe90eefd38a96cc7577e2d28b135cae0 /Doc/includes/email-headers.py
parentb808d590a24066bc03d21b55ed5e890a012477a8 (diff)
downloadcpython-git-f9e3cf1f9f6eaefba19593783e1cdf7681d1fa65.tar.gz
Issue #23511: Port email-simple.py to Python 3.
Also, update email examples to use the context manager version of open(). Patch by Baptiste Mispelon.
Diffstat (limited to 'Doc/includes/email-headers.py')
-rw-r--r--Doc/includes/email-headers.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Doc/includes/email-headers.py b/Doc/includes/email-headers.py
index a53317dbd8..89c8f3af32 100644
--- a/Doc/includes/email-headers.py
+++ b/Doc/includes/email-headers.py
@@ -1,8 +1,9 @@
# Import the email modules we'll need
from email.parser import Parser
-# If the e-mail headers are in a file, uncomment this line:
-#headers = Parser().parse(open(messagefile, 'r'))
+# If the e-mail headers are in a file, uncomment these two lines:
+# with open(messagefile) as fp:
+# headers = Parser().parse(fp)
# Or for parsing headers in a string, use:
headers = Parser().parsestr('From: <user@example.com>\n'