[Python-checkins] bpo-38351: Modernize email examples from %-formatting to f-strings (GH-17162)

Miss Islington (bot) webhook-mailer at python.org
Fri Nov 15 04:11:52 EST 2019


https://github.com/python/cpython/commit/dae27cc8e72106c2eceeff9af83d1e58b2bb68d5
commit: dae27cc8e72106c2eceeff9af83d1e58b2bb68d5
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-11-15T01:11:48-08:00
summary:

bpo-38351: Modernize email examples from %-formatting to f-strings (GH-17162)

(cherry picked from commit e8acc865a3f112b98417f676c897ca6ec2dac2c7)

Co-authored-by: Andrey Doroschenko <dorosch.github.io at yandex.ru>

files:
A Misc/NEWS.d/next/Documentation/2019-11-15-09-22-28.bpo-38351.xwhlse.rst
M Doc/includes/email-dir.py
M Doc/includes/email-simple.py
M Doc/includes/email-unpack.py

diff --git a/Doc/includes/email-dir.py b/Doc/includes/email-dir.py
index 0dcfbfb4025c8..2fc1570e654db 100644
--- a/Doc/includes/email-dir.py
+++ b/Doc/includes/email-dir.py
@@ -41,7 +41,7 @@ def main():
         directory = '.'
     # Create the message
     msg = EmailMessage()
-    msg['Subject'] = 'Contents of directory %s' % os.path.abspath(directory)
+    msg['Subject'] = f'Contents of directory {os.path.abspath(directory)}'
     msg['To'] = ', '.join(args.recipients)
     msg['From'] = args.sender
     msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'
diff --git a/Doc/includes/email-simple.py b/Doc/includes/email-simple.py
index f69ef40ff04c9..07dc30fd066ea 100644
--- a/Doc/includes/email-simple.py
+++ b/Doc/includes/email-simple.py
@@ -12,7 +12,7 @@
 
 # me == the sender's email address
 # you == the recipient's email address
-msg['Subject'] = 'The contents of %s' % textfile
+msg['Subject'] = f'The contents of {textfile}'
 msg['From'] = me
 msg['To'] = you
 
diff --git a/Doc/includes/email-unpack.py b/Doc/includes/email-unpack.py
index e0a7f01f58bb5..c8cb0be456083 100644
--- a/Doc/includes/email-unpack.py
+++ b/Doc/includes/email-unpack.py
@@ -43,7 +43,7 @@ def main():
             if not ext:
                 # Use a generic bag-of-bits extension
                 ext = '.bin'
-            filename = 'part-%03d%s' % (counter, ext)
+            filename = f'part-{counter:03d}{ext}'
         counter += 1
         with open(os.path.join(args.directory, filename), 'wb') as fp:
             fp.write(part.get_payload(decode=True))
diff --git a/Misc/NEWS.d/next/Documentation/2019-11-15-09-22-28.bpo-38351.xwhlse.rst b/Misc/NEWS.d/next/Documentation/2019-11-15-09-22-28.bpo-38351.xwhlse.rst
new file mode 100644
index 0000000000000..8e0dc9eb4ca2f
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2019-11-15-09-22-28.bpo-38351.xwhlse.rst
@@ -0,0 +1 @@
+Modernize :mod:`email` examples from %-formatting to f-strings.
\ No newline at end of file



More information about the Python-checkins mailing list