COMP1531

8.3 - Python - (Bonus) Classes

 

Author: Hayden Smith 2021

Let's discuss

Sending Emails

This is one of the more challenging parts of Iteration 3. You can create a dummy gmail account and make sure it is a less secure app.

 

Once that is done, you can usually search around the internet for python-based SMTP libraries that will allow you to send emails.

 

Work collaboratively with your team to solve this problem.

Storing and serving images

Fetching image via URL

(imgDown.py)

Cropping image

(week8/crop.py)

Serving image

(week8/static.py)

Using threads & timers

Most of what we do in python is single-threaded, i.e. if an action takes a while to complete, the program stops and waits for that action to be complete.

 

To do more interesting things like "set a timer to execute code later" we need to use the threading library so that multiple paths/streams of the program can be completed concurrently.

 

Using threads & timers

import threading
import time

def hello():
    print("hello, Timer")

if __name__ == '__main__':
    t = threading.Timer(3.0, hello)
    t.start()

timer.py

source: https://www.bogotobogo.com/python/Multithread/python_multithreading_subclassing_Timer_Object.php

Feedback

Made with Slides.com