Skip to content

Commit e8acc86

Browse files
doroschtaleinat
authored andcommitted
bpo-38351: Modernize email examples from %-formatting to f-strings (GH-17162)
1 parent b44ffc8 commit e8acc86

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

Doc/includes/email-dir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def main():
4141
directory = '.'
4242
# Create the message
4343
msg = EmailMessage()
44-
msg['Subject'] = 'Contents of directory %s' % os.path.abspath(directory)
44+
msg['Subject'] = f'Contents of directory {os.path.abspath(directory)}'
4545
msg['To'] = ', '.join(args.recipients)
4646
msg['From'] = args.sender
4747
msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'

Doc/includes/email-simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# me == the sender's email address
1414
# you == the recipient's email address
15-
msg['Subject'] = 'The contents of %s' % textfile
15+
msg['Subject'] = f'The contents of {textfile}'
1616
msg['From'] = me
1717
msg['To'] = you
1818

Doc/includes/email-unpack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def main():
4343
if not ext:
4444
# Use a generic bag-of-bits extension
4545
ext = '.bin'
46-
filename = 'part-%03d%s' % (counter, ext)
46+
filename = f'part-{counter:03d}{ext}'
4747
counter += 1
4848
with open(os.path.join(args.directory, filename), 'wb') as fp:
4949
fp.write(part.get_payload(decode=True))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Modernize :mod:`email` examples from %-formatting to f-strings.

0 commit comments

Comments
 (0)