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.
享受 3 個月的 Coursera Plus 40% 的折扣,節省讓您 閃耀的技能。立即保存

推荐体验
推荐体验
中级
Ideal for Python developers with basic object-oriented programming knowledge, looking to deepen their understanding of Python's data model.
推荐体验
推荐体验
中级
Ideal for Python developers with basic object-oriented programming knowledge, looking to deepen their understanding of Python's data model.
您将学到什么
Implement custom object behaviors using Python’s data model protocols.
Use special methods to manage object representation, creation, and deletion.
Build dictionary-like custom objects with iterable behavior.
Master custom numeric operators and implement complex math operations.
要了解的详细信息

添加到您的领英档案
May 2026
9 项作业
了解顶级公司的员工如何掌握热门技能

该课程共有8个模块
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.
涵盖的内容
6个视频
6个视频•总计109分钟
- Overview•2分钟
- Creating and Initializing an Instance•24分钟
- Representing an Instance: str and repr•20分钟
- Representing an Instance: format•24分钟
- Representing an Instance: bytes•16分钟
- Deleting an Instance•21分钟
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.
涵盖的内容
3个视频1个作业
3个视频•总计66分钟
- Objects as Iterables•25分钟
- Getting Items•17分钟
- Setting and Deleting Items•24分钟
1个作业•总计15分钟
- Containers - Assessment•15分钟
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.
涵盖的内容
4个视频1个作业
4个视频•总计103分钟
- Obtaining the Boolean Representation•23分钟
- Equality and Inequality•26分钟
- Greater and Less•23分钟
- Hashing and Slots•31分钟
1个作业•总计15分钟
- Comparables - Assessment•15分钟
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.
涵盖的内容
14个视频1个作业
14个视频•总计310分钟
- Adding•26分钟
- Subtracting•19分钟
- Multiplying•15分钟
- Dividing•26分钟
- Modulo and Powers•27分钟
- Bit Shifting Operations•22分钟
- Bitwise Logical Operations•26分钟
- Negative and Positive•19分钟
- Absolute Value and Inverse•28分钟
- Integers and Floats•20分钟
- Rounding•16分钟
- Floor and Ceiling•23分钟
- Truncation and Indexing•24分钟
- Complex Number•18分钟
1个作业•总计15分钟
- Numbers - Assessment•15分钟
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.
涵盖的内容
4个视频1个作业
4个视频•总计88分钟
- Getting Attributes•22分钟
- Setting and Deleting Attributes•19分钟
- Descriptors: Property Decorators•22分钟
- Descriptors: Creating a Custom Descriptor•26分钟
1个作业•总计15分钟
- Attributes - Assessment•15分钟
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.
涵盖的内容
1个视频1个作业
1个视频•总计20分钟
- Making an Object Callable•20分钟
1个作业•总计15分钟
- Functions - Assessment•15分钟
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.
涵盖的内容
1个视频1个作业
1个视频•总计21分钟
- Clean Up with Context Managers•21分钟
1个作业•总计15分钟
- Context Managers - Assessment•15分钟
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.
涵盖的内容
2个视频3个作业
2个视频•总计48分钟
- Copying Objects•24分钟
- Pickling: Get and Set State•24分钟
3个作业•总计90分钟
- Full Course Practice Assessment•15分钟
- Serialization - Assessment•15分钟
- Full Course Assessment•60分钟
位教师

提供方

提供方

Packt helps tech professionals put software to work by distilling and sharing the working knowledge of their peers. Packt is an established global technical learning content provider, founded in Birmingham, UK, with over twenty years of experience delivering premium, rich content from groundbreaking authors on a wide range of emerging and popular technologies.
人们为什么选择 Coursera 来帮助自己实现职业发展

Felipe M.

Jennifer J.

Larry W.

Chaitanya A.
常见问题
The Python Data Model course delves into Python's internal mechanisms that govern object behavior. It covers various protocols and methods in Python, such as iteration, string representation, comparison, operator overloading, and more. This course is essential for anyone looking to deepen their Python expertise, particularly when creating custom classes and behaviors. By understanding how Python's data model works, you'll be able to write more efficient, flexible, and powerful Python code, especially when working with complex data structures.
After completing the Python Data Model course, you'll have a thorough understanding of how Python works under the hood. You'll be able to implement custom behaviors for your classes using various magic methods like __str__, __init__, __getitem__, __add__, and more. You'll be able to create objects that behave like built-in types and can be integrated seamlessly with Python’s iteration, comparison, and arithmetic systems. This knowledge will make you proficient in advanced Python programming, empowering you to work with custom data structures and interact with Python's rich set of protocols.
To get the most out of this course, you should have a solid understanding of basic Python programming concepts, such as classes, functions, and data types. Familiarity with object-oriented programming (OOP) principles is also helpful. While this course does not require expert-level knowledge, it is designed for those who are comfortable with the basics of Python and want to advance their understanding of Python's internals and the Python data model.
This course is for Python developers who want to deepen their understanding of how Python works behind the scenes. It is particularly useful for those working on advanced Python projects involving custom classes and objects, or those who are looking to level up their skills in Python's object-oriented programming. If you're interested in understanding Python's data model in-depth and writing highly customizable code, this course is for you.
The Python Data Model course consists of 12 hours of video content, designed to be consumed at your own pace. The time you take to complete the course will depend on your experience level and how much time you dedicate to practicing the concepts, but on average, you can expect to spend approximately 12 hours to finish the course.
In real-world Python programming, understanding the data model allows you to create more efficient, maintainable, and reusable code. It equips you with the ability to make your custom classes work seamlessly with Python’s built-in features, such as iterators, context managers, arithmetic operations, and more. This advanced knowledge can be applied across many domains, such as data science, web development, and automation, where custom classes are often needed.
Throughout the course, you'll explore a variety of topics related to Python's data model, including object creation, initialization, and representation methods like __str__, __repr__, and __format__. You will also cover how to define custom behaviors for iteration, comparison, arithmetic operations, attributes, and more. With this knowledge, you'll be able to customize Python objects and make them behave in ways that are native to Python, making your code more powerful and flexible.
No, this course is not part of a specialization. It is a stand-alone course that focuses solely on Python’s data model, ideal for anyone looking to deepen their understanding of Python’s internal workings and how to customize Python classes for advanced use cases.
Yes, you can preview the first video and view the syllabus before you enroll. You must purchase the course to access content not included in the preview.
If you decide to enroll in the course before the session start date, you will have access to all of the lecture videos and readings for the course. You’ll be able to submit assignments once the session starts.
Once you enroll and your session begins, you will have access to all videos and other resources, including reading items and the course discussion forum. You’ll be able to view and submit practice assessments, and complete required graded assignments to earn a grade and a Course Certificate.
If you complete the course successfully, your electronic Course Certificate will be added to your Accomplishments page - from there, you can print your Course Certificate or add it to your LinkedIn profile.
This course is currently available only to learners who have paid or received financial aid, when available.
Yes. In select learning programs, you can apply for financial aid or a scholarship if you can’t afford the enrollment fee. If fin aid or scholarship is available for your learning program selection, you’ll find a link to apply on the description page.
更多问题
提供助学金,



