This course provides a general overview of Python basics needed to create successful object oriented Python applications. It then goes into detail in creating object oriented Python applications and provides instructions on the creation of common design patterns in Python. The course finishes up with recommendations on increasing performance of your Python applications whether it be for reducing memory or decreasing the run time of an application.
What am I going to get from this course?
Create high high-performance objects and applications that can be used in production environments
Prerequisites and Target Audience
What will students need to know or do before starting this course?
Although students will learn basic Python syntax needed to begin object oriented development in Python, students should be familiar with the general programming terminology and logic such as if and else statements. They should also be familiar with the general idea of class object concepts such as inheritance.
Students should know how to install applications on their system and install Python 3.
Who should take this course? Who should not?
Students that would like to learn advanced Python techniques will benefit from this course. Also, those students used to another programming language and want to create Python applications for the first time may also benefit. This course dives into utilizing Python for creating advanced class objects and optimizing them for production value. Students that already know advanced object oriented Python techniques may not benefit from this course.
Module 1: Python Basics
This is a general overview of the course.
Python Basics Overview
An overview of the items discussed relating to Python basics.
Python Interpreter and the Versions Available
Learn why python is an interpreted language. We will also discuss the versions of Python available and why you would choose one version over the other.
Why Choose Python
Know the reasons for choosing Python to build your application.
Your Python Environment
Installing Python on Common Systems: An overview of installing and running Python on different environments.
Environment: Learn some common settings you may need to run your Python application.
Pip: Pip is a popular application used to access Python package repositories. You will learn common pip commands to find and install the package you need.
Project File Structure: Learn how the file structure of your project will affect how your Python application runs and how package modules are utilized.
Python Environment Quiz
Be prepared to setup your environment for Python development.
Assignment: Setup your Project
Setup your project in preparation of the Python Class Object module.
Overview of the content being covered by the syntax module. Python variables are also covered in this lecture.
Logical and Bitwise Operators
Learn common logical and bitwise operators to write successful Python applications.
Defining Methods and Main
Define methods and parameters. Also, define a main function and understand “__name__.” The variable scopes local and global are demonstrated.
Dictionaries, Tuples, and Lists
Know the difference and when to use a dict, list, or tuple.
Strings and Formatters
Strings, Unicode, and string formatters are demonstrated. Also, string encoding will be discussed.
Python has powerful anonymous functions called lambdas. You learn how to use them and their advantages.
Python Basics Quiz
Be sure you are familiar with the basics of Python syntax to continue with the next module.
Fizz Buzz Assignment
A common Python interview question is to solve the FizzBuzz puzzle. The FizzBuzz puzzle goes as follows for the integers 1 through 100 print on each line "Fizz" if the integer is divisible by 3, "Buzz" if the number is divisible by 5, "FizzBuzz" if the number is divisible by 3 and 5, and print the integer value for all other cases. The solution should look like the following for the numbers 1 through 20.
Create a script that runs by the command "python fizzbuzzsolution.py" on your system. In your solution use a for loop or in line for loop and if or inline if statements. Define a method for your solution called "print_fizz_buzz" and be sure to call your method from a method that you define as your main method.
Module 3: Python Class Objects
Overview of the Python class objects module
Creation and Instantiation
Create and instantiate a Python class. Know how to create a class constructor.
Python Class Attributes
Create protected, private, and public attributes. Know the difference and their behavior in Python.
Python Instance Class Attributes
Know the difference between class attributes (static types in some languages) and instance attributes.
Inheritance in Python
Know what a super class is and create classes that inherit from a super class. Understand the super method call in an inherited method.
Implement the commonly used interface design pattern in Python and make sure your method stubs are implemented when inherited.
Class Factory - Factory by If Statements
Implement a class factory to maintain the creation of new object types.
In this lecture we implement the factory pattern using if statements.
Class Factory - Metaclasses
Implement a class factory to maintain the creation of new object types.
In this lecture we implement the factory pattern using a metaclass.
Learn the method to inherit attributes from many parent classes if you must.
Be familiar with class decorators such as @property, @staticmethod, and @classmethod.
Customize custom behaviors such a printing your custom object by overriding base methods such as __str__.
Custom Base Object, Collections, and Dict Objects
Inherit from base objects such as list to create your own complex objects or collection of objects.
Custom Base Object, Collections, and Dict Objects - Demonstrate Custom List Container
Inherit from base objects such as list to create your own complex objects or collection of objects. In this lecture we demonstrate the functionality of the custom list container we created.
Python Class Objects
Be familiar with Python class object concepts and design patterns to create successful applications that are ready for a production environment.
Assignment: Inherit from the dictionary class
Create a class that inherits from the dictionary class.
Python Class Objects Source Code
Download the source code used for the demonstrations of this lecture.
Module 4: Enhancing Performance
Enhancing Performance Introduction
Overview of the lectures in the Python optimization module.
Loading and Unloading Data Quickly
Use cPickle to serialize and unserialize data from storage.
Options for Reducing the Amount of Memory Being Used
Python includes features out of the box such as using “yield” for generators for reducing the amount of memory being utilized at one time. Learn by example how to utilize this powerful feature.
Multi-threading and Multi-processing
Know the difference between the two methods and know when to use them to decrease the run times of your application jobs.
Use Specialized Packages for the Right Job
Be aware of the correct packages to utilize for your needed functionality. There may exist packages tuned to maximize the performance of your task.
Compile to C
Learn to use Cython to compile a Python application to C objects.
Utilize your GPU for Maximum Performance
Learn about the popular Python packages created so you can take advantage of the many GPU cores that exist in 3D graphics cards today.
Be ready to optimize your applications whether you need to reduce the run time of your application or make it fit into memory.
Complete the optimization assignment.
Enhancing Performance Source Code
Download the source code used in the module demonstrations.