Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Coursera

Python Data Model

Packt via Coursera

Overview

AI, Data Science & Cloud Certificates from Google, IBM & Meta — 50% Off
One plan covers every Professional Certificate on Coursera. 50% off Coursera Plus Annual for 10 days only — price increases June 17.
Unlock All Certificates
This course features Coursera Coach! A smarter way to learn with interactive, real-time conversations that help you test your knowledge, challenge assumptions, and deepen your understanding as you progress through the course. In this course, you'll explore the Python data model, learning about the core protocols Python uses to enable iteration, context management, string representation, and much more. With practical demonstrations, you will understand the inner workings of custom classes and how Python handles object behavior like iteration, comparison, and operator overloading. Through the modules, you’ll dive deep into creating and managing custom objects, learning how to use special methods for object representation, deletion, and much more. This journey will guide you through powerful tools such as context managers, serialization, and implementing custom container-like behavior. This course is ideal for intermediate Python developers who want to level up their skills. You should have a basic understanding of Python and object-oriented programming. By the end of the course, you will be able to implement custom object behaviors using the Python data model, enhance your code with advanced features, and understand how to use Python's built-in protocols to build more efficient programs.

Syllabus

  • Basics
    • In this module, we will explore the essential building blocks of Python's data model, focusing on object creation, initialization, and how to represent objects in custom ways. You’ll also learn to control object deletion behavior using the __del__ method. These foundational skills will help you create flexible and reusable Python classes.
  • Containers
    • In this module, we will dive into how custom objects can behave like built-in containers, such as lists or dictionaries. You'll learn to make your objects iterable and give them the ability to store and manipulate items like a dictionary. This module will expand your Python class design skills by integrating custom data structures.
  • Comparables
    • In this module, we will cover how to make custom objects comparable, enabling equality checks and Boolean evaluations. You'll also learn how to define the ordering of objects, allowing them to be compared using greater than, less than, and equality operators. These comparisons make your objects more versatile and integrated with Python’s built-in systems.
  • Numbers
    • In this module, we will focus on enabling custom objects to perform arithmetic and bitwise operations. You’ll learn how to override operators like addition and subtraction to work with your own types. Additionally, we’ll explore customizing operations like modulo, powers, and bit-shifting, bringing your objects closer to behaving like numeric types.
  • Attributes
    • In this module, we will explore how to control and manipulate object attributes. You’ll learn how to intercept and customize the behavior when reading, setting, and deleting attributes. Additionally, we will cover descriptors and the property decorator, which allows you to add custom logic to your object’s attributes.
  • Functions
    • In this module, we will explore how to make custom objects behave like functions. By using the __call__ method, you can turn your objects into callable entities, enabling dynamic and flexible design patterns. This skill is useful for when your objects need to function as both data structures and functional components.
  • Context Managers
    • In this module, we will focus on using context managers in Python. You will learn how to define custom context managers using __enter__ and __exit__ to manage resources such as file handles or database connections. This will help you write cleaner, more efficient code for managing resources with automatic cleanup.
  • Serialization
    • In this module, we will cover the advanced topic of object serialization. You’ll learn how to copy objects effectively and explore the differences between shallow and deep copies. Additionally, you will learn how to use the pickle module to save and load objects, customizing the serialization process with __getstate__ and __setstate__. This will ensure your custom objects can be easily saved and restored.

Taught by

Packt - Course Instructors

Reviews

Start your review of Python Data Model

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.