Python Coding Techniques: Using OOP, Decorators, Generators, and Applying Good Pythonic Design Paradigms
Duration: 30 hours (10 days @ 3 hours per day)
Course Track: Intermediate / Lateral
About the Course
This master class is designed to enrich your knowledge of Object-Oriented Programming (OOP) concepts using Python. You will undergo in-depth learning of OOP design paradigms and apply them in your Python code, emphasizing good program design for building scalable and maintainable Python applications/libraries.
Target Audience
This training class is intended for engineers and coding enthusiasts with a basic understanding of Python programming concepts, including Python syntax, flow control, basic data types, functions, and knowledge of basic standard library modules.
Prerequisites
Participants should be familiar with core Python programming concepts, including Python syntax, flow-control constructs, built-in data types, functions and modules, built-in functions, and basic standard library modules.
Course Objectives
- Learn and understand OOP preliminaries – the Pythonic way.
- Design and develop Python programs using OOP-based design.
- Learn functional programming techniques using Python.
- Learn some commonly used design patterns in Python.
- Learn how to implement AOP patterns using decorators in Python.
- Learn how to leverage concurrent programming using generators and co-routines in Python.
What Will NOT be Covered
- Python fundamentals.
- Text processing in Python.
- Process and network automation-related library modules/concepts.
- Multi-threading, multiprocessing miscellaneous Python libraries.
- Web programming or web automation.
- Any third-party library/modules.
Training Mode
This training program is designed to be a live master class conducted via Google Meet. Most concepts will be explained by live coding – attendees are expected to learn by interacting with the master and trying out short exercises provided by the master.
Training Requirements
As the training will be a live master class, each attendee must have a working computer/laptop with reliable internet connectivity for practice sessions and have the following software installed on their computer/laptop:
- Python 3.10 or above installed and configured [Download available at python.org/downloads or from Microsoft Store for Windows users. You can also use Anaconda Python from anaconda.com/downloads]
- Visual Studio Code with Python extensions enabled. [Download from code.visualstudio.com/Download]
Module 1
A Primer on OOP Concepts
Procedural Programming vs OOP
- When should you choose OOP over procedural paradigm in your code
- Understanding structured programming, modularity, extensibility, and delegation of concerns
Essential Traits of OOP-based Design
- Instantiability
- Extensibility
- Modularity
- Comprehensibility
- Introspectability
OOP Design Concepts Explained
- Abstraction
- Encapsulation
- Generalization
- Composition
- Delegation
- Polymorphism
- Contracts / Protocols / Interfaces
- Dynamic Dispatch
Module 2
OOP Using Python – Basic Concepts
- Python Language OOP Design Features
- All about names, values, objects, and types
- Everything in
Python
as an object - Accessing objects using references
- Functions, classes, and methods as objects
- Variables vs Attributes
- Scope of a variable vs attribute resolution
- Modules and namespaces
- Objects as values in different contexts: numeric, boolean, string, containers, and iterables
- Python Objects Memory Model
- Python 3 Type and Object Hierarchy
- Introspecting Objects in
Python
: id()
,type()
,dir()
hasattr()
,getattr()
,setattr()
, anddelattr()
isinstance()
,vars()
str()
,repr()
,bool()
callable()
,iter()
,reversed()
,len()
Module 3
Creating Custom Classes and Objects in Python Code
- Defining classes and instantiating objects.
- Variables vs Attributes: how are they different in
Python
.
- Significance of defining and using classes
- When should you avoid defining your own classes
- An overview on class attributes:
__name__
, __bases__
, __doc__
, __dict__
, __class__
.
- Instances and instance attributes.
- Class-Instance relationship: rules and bindings.
- Instance methods, class-methods, static-methods, and singleton-instance methods.
- Sub-classing, Inheritance, and Generalization
- Ducktyping vs Generalization
- Understanding Monkey-patching techniques with use-case examples.
Creating Custom Classes and Objects in Python Code
- Defining classes and instantiating objects.
- Variables vs Attributes: how are they different in
Python
. - Significance of defining and using classes
- When should you avoid defining your own classes
- An overview on class attributes:
__name__
,__bases__
,__doc__
,__dict__
,__class__
.- Instances and instance attributes.
- Class-Instance relationship: rules and bindings.
- Instance methods, class-methods, static-methods, and singleton-instance methods.
- Sub-classing, Inheritance, and Generalization
- Ducktyping vs Generalization
- Understanding Monkey-patching techniques with use-case examples.
Module 4
Special Methods Part 1: Implementing Life-cycle Methods and Common Object Features
- The life-cycle methods:
__new__()
,__init__()
, and__del__()
methods.- Implementing context management support for an object:
__enter__()
and__exit__()
methods.- Using
contextlib
module for implementing context manager support - Exposing object as a value:
- String representations:
__str__()
,__bytes__()
, and__repr__()
methods. - Numeric representations:
__int__()
and__float__()
methods. - Boolean representation:
__bool__()
method. - Implementing comparability:
__lt__()
,__gt__()
,__le__()
, and__ge__()
methods__eq__()
and__ne__()
methods.- Simplifying comparability implementation using
functools.total_ordering
decorator - Implementing custom callable objects using the
__call__()
method
Module 5
Special Methods Part 2: Custom Implementation of Common Data-Types
- Implementing custom numeric types:
- Arithmetic support:
__add__()
,__sub__()
,__mul__()
,__mod__()
,__truediv__()
, and__pow__()
methods - Bitwise operation support:
__or__()
,__and__()
,__xor__()
,__lshift__()
, and__rshift()
methods. - Using the
operator
module – use-case examples. - Implementing custom container/collection types:
__len__()
,__contains__()
, and__iter__()
methods.- An overview of the iterator protocol.
- Implementing sequence container objects:
__getitem__()
,__add__()
,__mul__()
, and__reversed__()
,count()
, andindex()
methods.- Mutable sequence emulation using
__setitem__()
,__delitem__()
,__iadd__()
,__imul__()
,append()
,extend()
,insert()
,remove()
,pop()
,copy()
,clear()
,sort()
,reverse()
methods. - Implementing custom set and mapping containers.
- Implementing custom attribute accessors:
__getattr__()
,__setattr__()
,__delattr__()
,__dir__()
methods.- Implementing object attributes using
__slots__
support. - Implementing attribute accessors methods using
property()
function and decorator.
Module 6
Decorators and AOP Features
- An overview on Decorator patterns and AOP
- Using
python
annotation syntax to create decorators - Creating decorators with arguments (parameterized decorators).
- Chaining decorators.
- Dependency injection features: before, after, and around filters.
- Implementing decorators using classes.
- Decorating classes and methods of a class.
- Decorating
python
modules. - Use-case examples and best practices for implementing decorators.
Module 7
Beyond OOP: Functional Programming Features in Python
- An overview on functional programming
- Functions as first-class citizen
- Pure functions vs Functions with side-effects
- Lambda expressions in
Python
- Higher-order functions – examples and use-cases
- Monads – the
pythonic
way - Partials and Currying functions in
Python
- A tour into features provided by the
functools
module with examples
Module 8
Concurrent Programming in Python: Using Generators and Co-routines
- A gentle introduction to concurrent programming
- Understanding the concurrency problem while using imperative programming style.
- Implementing concurrency using generators in
Python
. - Creating a generator using
yield
statement. - Interesting generator patterns in the
itertools
module. - Creating custom iterators for collections.
- Creating co-routines using
yield
expressions. - Using
async
andawait
features to implement co-routines. - Designing concurrent execution pipe-lines
- An overview on the
asyncio
library.
Module 9
A Pythonic Approach Towards Applying Map, Filter and Reduce Operations on Datasets
- An overview on
map()
,filter()
, andfunctools.reduce()
functions - A gentle introduction to comprehensions
- Creating lists, tuples, sets, and dictionary using comprehensions
- Applying
map
andfilter
operations using comprehensions - Generator comprehensions.
- Use-case examples for applying comprehensions for various problem-statements
Module 10
Odds and Ends
- An overview on
python's
garbage collector implementation and using thegc
module. - Nuances of different
Python
implementations:CPython
vsPyPy
vsMicropython
. - An overview on
python
meta-programming features and use-cases. - Diagnostics, profiling, instrumentation, and debugging techniques using standard library modules.
OO
Design:Pythonisms
and best practices.
Course fee: ₹9000 INR / $150 USD / £120 GBP / €140 EUR (to be paid in advance for enrollment)
How to enroll ?
In order to enroll to this training class, you can fill in the form below registering your interest with the required details.
You will receive an acknowledgement email from registrations@slashprog.com once you submit the form. In this email, we will provide you with the details for paying the course fee including payment links if you chose “Pay via Stripe” or UPI/NEFT details if you chose UPI/NEFT payment option.
Once we receive the payment, we will reply back with the confirmation of your training registration and provide you links to connect using Google Meet along with the exact schedule for the classes by email.
If you have any further queries, you can email us directly to contact@slashprog.com