forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This lets us "normalize" CPython source code so that we can now reformat just the code snippets. That in turn will let us look at the code snippet formatting diff more carefully.
- Loading branch information
1 parent
1619f43
commit b911e9a
Showing
1,668 changed files
with
268,585 additions
and
209,276 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Import the email modules we'll need | ||
#from email.parser import BytesParser | ||
# from email.parser import BytesParser | ||
from email.parser import Parser | ||
from email.policy import default | ||
|
||
|
@@ -9,17 +9,18 @@ | |
|
||
# Or for parsing headers in a string (this is an uncommon operation), use: | ||
headers = Parser(policy=default).parsestr( | ||
'From: Foo Bar <[email protected]>\n' | ||
'To: <[email protected]>\n' | ||
'Subject: Test message\n' | ||
'\n' | ||
'Body would go here\n') | ||
"From: Foo Bar <[email protected]>\n" | ||
"To: <[email protected]>\n" | ||
"Subject: Test message\n" | ||
"\n" | ||
"Body would go here\n" | ||
) | ||
|
||
# Now the header items can be accessed as a dictionary: | ||
print('To: {}'.format(headers['to'])) | ||
print('From: {}'.format(headers['from'])) | ||
print('Subject: {}'.format(headers['subject'])) | ||
print("To: {}".format(headers["to"])) | ||
print("From: {}".format(headers["from"])) | ||
print("Subject: {}".format(headers["subject"])) | ||
|
||
# You can also access the parts of the addresses: | ||
print('Recipient username: {}'.format(headers['to'].addresses[0].username)) | ||
print('Sender name: {}'.format(headers['from'].addresses[0].display_name)) | ||
print("Recipient username: {}".format(headers["to"].addresses[0].username)) | ||
print("Sender name: {}".format(headers["from"].addresses[0].display_name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.