...

/

Puzzle 6: Explanation

Puzzle 6: Explanation

Let’s find out how modules work in Python.

We'll cover the following...

Let’s try it!

Try executing the code below to verify the results:

Press + to interact
from email.message import EmailMessage
msg = EmailMessage()
msg['From'] = 'xyz@someCompany.com'
msg['To'] = 'ABC <abc@privateCompany.com>'
msg.set_content('''\
Dear Sir.
I'm here to learn Python.
...
''')
print(msg)

Explanation

When Python looks for a module to import (email, for example), it’ll go over the directories in sys.path and try to find a module matching the name. The first value in sys.path is '' (the empty string). The value '' stands for the current directory in which we have the teaser file email.py ...