Python: OOP and Pythonic Paradigms


Learn how to design and develop clean, efficient and maintainable python applications using Object-Oriented-Programming concepts. Also learn how to apply various concepts of OOP design and paradigms using the pythonic approach. 

Training Agenda

Day 1

Classes and Objects

  • Objects, Types, Classes and Values in Python.
  • Introspection of objects:
      • id(), type(), dir()
      • hasattr(), getattr(), setattr(), delattr()
      • isinstance(), vars()
      • str(), repr(), bool()
      • callable(), iter(), reversed(), len()
  • Python 3 OOP architecture
  • Defining classes and instantiating objects.
  • Classes and class attributes.
      • __name__, __bases__, __doc__, __dict__, __class__.
  • Instances and instance attributes.
  • Class-Instance relationship: rules and bindings.
  • Instance methods, class-methods and static-methods.
  • More about the @classmethod and @staticmethod decorator
  • Python special methods:
      • Life-cyle methods: __new__(), __init__(), __del__()
      • Representational methods: __str__(), __repr__(), __len__(), __nonzero__()
      • Comparison methods: __eq__(), __ne__() and family.
    • Inheritance and Generalization techniques using Liskov Substitution Principle (LSP).
  • Multiple inheritance support in Python: best practices and trade-offs.
  • Using Duck-Typing as an alternative to Generalization approach.
  • An overview on ABCs (available from Python 3.5).
  • An overview on monkey-patching of Python built-ins, modules, user-defined functions, classes and their instances.
  • Encapsulation in Python: best practices and trade-offs.

Day 2

Python data model methods (demonstrations / examples)

  • Implementing context managers:
    • __enter__(), __exit__()
    • An overview on contextlib module
  • Emulating numerical types:
    • __add__(), __sub__(), __mul__(), __truediv__()
    • __mod__(), __pow__(), __floordiv__(), __divmod__()
    • __iadd__(), __isub__() and family.
    • Bitwise operators – __lshift__(), __rshift()__ and family.
  • Emulating subscriptability:
    • __getitem__(), __setitem__(), __delitem__()
  • Emulating containers and iterable objects:
    • __len__(), __iter__(), __next__()
  • Emulating callable objects using __call__() method
  • Implementing custom accessors:
    • __getattr__(), __setattr__(), __delattr__()
    • Using @property decorator on implementing accessor patterns
    • Using __slots__ for implementing instance attributes

Day 3

Decorators and AOP features

  • Creating and using decorators in Python.
  • Creating decorators with arguments (parameterized decorators)
  • Decorator-chaining (nested decorators).
  • Dependency injection features: before, after and around filters.
  • Sample use-cases and best practices for using decorators.
  • Class-based decorators vs function-based decorators: best practices

Creating generators, iterators and co-routines.

  • Understanding the concurrency problem while using standard procedural programming paradigm.
  • Implementing concurrency using generators in Python.
  • Creating a generator using yield statement.
  • Interesting generator patterns in the itertools module.
  • Creating co-routines using yield expressions.
  • Creating execution-pipelines using generators and co-routines.
  • An overview on asyncio based co-routines.
Next schedule
from April 5th, 2023 – 9:30 AM IST
About Instructor
Mr. Chandrashekar Babu is a FOSS Technologist and an eminent corporate trainer for various topics in the Linux ecosystem. His journey into the Linux ecosystem started as an enthusiast in the year 1995. Since then, he has been exploring, learning and hacking on various Free/Open Source Software tools and has been delivering training on the same since the year 2003. He maintains his own website at the URL:

Training duration: 3 days (6 hours per day)
Training delivery: Online via Zoom meeting
Price:  ₹9,000/-