mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	bpo-38351: Modernize email examples from %-formatting to f-strings (GH-17162)
This commit is contained in:
		
							parent
							
								
									b44ffc8b40
								
							
						
					
					
						commit
						e8acc865a3
					
				
					 4 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Modernize :mod:`email` examples from %-formatting to f-strings.
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue