Skip to content

Commit 9583f64

Browse files
committed
Fix format string
1 parent 4d231bc commit 9583f64

4 files changed

Lines changed: 5 additions & 3 deletions

File tree

Doc/includes/email-dir.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ def main():
3939
directory = args.directory
4040
if not directory:
4141
directory = '.'
42+
context = os.path.abspath(directory)
4243
# Create the message
4344
msg = EmailMessage()
44-
msg['Subject'] = 'Contents of directory %s' % os.path.abspath(directory)
45+
msg['Subject'] = 'Contents of directory {}'.format(context)
4546
msg['To'] = ', '.join(args.recipients)
4647
msg['From'] = args.sender
4748
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'] = 'The contents of {}'.format(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 = 'part-{:03}{}'.format(counter, 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 email example from %-formatting to f-string

0 commit comments

Comments
 (0)