August 2018
Intermediate to advanced
366 pages
10h 14m
English
The steps for this recipe are as follows:
EMAILS = [
{'sender': 'author1@domain.com', 'subject': 'First email',
'body': 'This is my first email'},
{'sender': 'author2@domain.com', 'subject': 'Second email',
'body': 'This is my second email'},
]
import cmd
import shlex
class MyMail(cmd.Cmd):
intro = 'Simple interactive email client.'
prompt = 'mymail> '
def __init__(self, *args, **kwargs):
super(MyMail, self).__init__(*args, **kwargs)
self.selected_email = None
def do_list(self, line):
"""list
List emails currently in the Inbox"""
for idx, email in enumerate(EMAILS):
print('[{idx}] From: {e[sender]} - {e[subject]}'.format( idx=idx, ...Read now
Unlock full access