Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Python Data Model
Rating: 4.5 out of 5(13 ratings)
178 students

Python Data Model

Magic Methods in Python Classes
Last updated 4/2020
English

What you'll learn

  • Use the double underscore or "magic" methods to shape the behavior of custom classes.
  • Overload operators in Python.
  • Create custom iterables using classes.
  • Create custom context manager classes.

Course content

8 sections35 lectures12h 44m total length
  • Overview2:05

    Python has a set of protocols that the language internally adhere to which provides the functionality for features such as iteration, context manager behavior, string representation of an object, and many other things. When you create custom classes in Python and make use of these protocols then you can create custom behavior in the context of iterations, types, comparison of objects, operator overloading, and much more. Knowing about these will help level up your Python skills. If you are ready to progress forward in your Python prowess, then join us to learn more about the Python data model.

  • Creating and Initializing an Instance24:26

    In this episode, Justin and Mike start exploring the Python protocols for creating and initializing object instances. Justin explores the differences between the new and init methods as well as when to consider using those methods.

  • Representing an Instance: str and repr20:17

    In this episode, Justin and Mike start exploring how you can represent an object for an output operation. Moreover, Justin discusses the nuanced differences between the str and repr methods as part of the Python data model protocol.

  • Representing an Instance: format24:11

    In this episode, Justin and Mike continue the exploration of output representations. Justin demonstrates the usage of the format method in order to provide custom string template formatting for users.

  • Representing an Instance: bytes16:25

    In this episode, Justin and MIke explore one final representation method that can be implemented in Python. Specifically, Justin demonstrates both a simple way to create a bytes object from a class as well as other processes that can be used when writing a custom bytes method.

  • Deleting an Instance21:06

    In this episode, Justin and Mike explore creating code when an object instance is deleted using the del method. Moreover, Justin discusses some of the pain points that can arise when relying on the del method within Python.

Requirements

  • Familiarity with classes and object-oriented programming.
  • Python programming experience.

Description

Python Data Model

Python has a set of protocols that the language internally adhere to which provides the functionality for features such as iteration, context manager behavior, string representation of an object, and many other things. When you create custom classes in Python and make use of these protocols then you can create custom behavior in the context of iterations, types, comparison of objects, operator overloading, and much more. Knowing about these will help level up your Python skills. If you are ready to progress forward in your Python prowess, then join us to learn more about the Python data model.

Course Format

•          Binge-worthy TV shows! Watch comprehensive, in-depth episodes that use a talk show-like format to keep you engaged while learning.

•          You can pick and choose episodes or you can watch as a complete series.

•          A little humor, anecdotes, and real-world examples.

Other Courses

Ready to a DevPro? Get more DevProTV training with a variety of topics. Join Justin and DevProTV to level up your programming prowess!

Updates and Versions

The programming world updates at a break neck pace. As a result, there are times that certain tools, editors, libraries have changed. While syntax or names may change, the foundations remain the same. Though we hope to keep things updated, there may be time before that can occur. I recommend seeing if you can translate between changes and if all fails, ask questions!

Who this course is for:

  • Intermediate Python programmers looking to develop more of an understanding of Python's "magic" methods.
  • Beginner Python programmers looking to level up their game.