module in python code example

Example 1: malier module python

from mailer import Mailer
from mailer import Message

message = Message(From="[email protected]",
                  To="[email protected]",
                  charset="utf-8")
message.Subject = "An HTML Email"
message.Html = """This email uses <strong>HTML</strong>!"""
message.Body = """This is alternate text."""

sender = Mailer('smtp.example.com')
sender.send(message)

Example 2: how to import python

import random
from os import name, system
import time as t

Example 3: python module

Simply, a module is a file consisting of Python code. A module can 
define functions, classes and variables. A module can also include 
runnable code that you can call with abitrary names attached to them.

Example 4: python os module

#the os module provides an operating system interface from Python
import os
#prints the name of the operating system
print(os.name)
#prints the absolute path for the module
print(os.getcwd())

Example 5: package in python

A package is basically a directory with Python files and a file with the name __init__.py

Example 6: modules in python

import numpy as np: