Udemy

The power of Special Methods in Python. Make better classes!

Enroll Now
  • 481 Students
  • Updated 4/2025
4.7
(50 Ratings)
CTgoodjobs selects quality courses to enhance professionals' competitiveness. By purchasing courses through links on our site, we may receive an affiliate commission.

Course Information

Registration period
Year-round Recruitment
Course Level
Study Mode
Duration
2 Hour(s) 1 Minute(s)
Language
English
Taught by
Loek van den Ouweland
Rating
4.7
(50 Ratings)
2 views

Course Overview

The power of Special Methods in Python. Make better classes!

Learn Python’s datamodel with operator overloading and emulate built-in types by implementing magic (dunder) methods

People say that python is an intuitive language to learn and use. Beginners write their first programs in no time and more advanced programmers make educated guesses how to use parts of Python they have never used before. Even third-party libraries seem to work exactly how you expected.

80% of our time we are using operators like +-/* to calculate, use for-loops to go through lists, use len() to count and indexers to access elements from lists. After a while you don't even have to think about these language features anymore. You just use them and expect things to work the same way everywhere.

But why and how does this work?

In this course, you learn how to design your classes and objects to support common language features so other programmers can make smart guesses about how to use them. You learn how to support iteration, subscripting (indexing), context managers, hashing, equality checking etc.

After this course, you are able to:

- Explain the origin of the names Python datamodel, magic methods, dunder methods and special methods.

- Write an indexer to support subscripting with the __getitem__ method

- Apply __iter__, __next__ to make your objects iterable

- Define the object identity

- Use __hash__ to make objects hashable

- Specify  language featureswith special methods __eq__, __ne__, __lt__, __gt__, __le__, __ge__

- Make objects callable with __call__

- Describe how objects are constructed by methods __new__ and __init__

- Wrap existing code into context managers with __enter__ and __exit__

The length of this course is 2 hours. Each topic shows clear examples of how to make your classes more Pythonic by implementing special methods, the secret weapon of your objects. This course has no exercises.

This course is meant for developer with basic Python experience who want to improve their skills or developers who bring experience from another language like c#, java, javascript, c++ and want to learn about Pythons unique language features.

This course is taught by Loek van den Ouweland, a senior software engineer with 25 years of experience. Loek is the creator of Wunderlist for windows, Microsoft To-do and Mahjong for Windows and has 15 years of experience teaching software engineering to a wide variety of students.

Course Content

  • 7 section(s)
  • 23 lecture(s)
  • Section 1 Course Introduction
  • Section 2 Data model
  • Section 3 Equality Operators
  • Section 4 Object Creation
  • Section 5 Container Objects
  • Section 6 More operators
  • Section 7 Special Cases

What You’ll Learn

  • Explain the origin of the names Python datamodel, magic methods, dunder methods and special methods.
  • Write an indexer to support subscripting with the __getitem__ method
  • Make objects callable with __call__
  • Define the object identity
  • Apply __iter__, __next__ to make your objects iterable
  • Specify object equality with __eq__, __ne__, __lt__, __gt__, __le__, __ge__
  • Wrap existing code into context managers with __enter__ and __exit__
  • Describe how objects are constructed by methods __new__ and __init__

Skills covered in this course


Reviews

  • A
    Agata.Jakubowska
    5.0

    Awesome Course! Nicely explained, a lot of knowledge. Thank you!

  • A
    Achal Garg
    3.0

    very high level explanation, missing reasoning

  • T
    Timothy Morgan
    5.0

    Interesting stuff - Another great course from Loek :) - He's an excellent instructor & his explanations of the topics are very clear - I highly recommend doing this course to further your Python understanding.

  • J
    Jonathan Bourland
    4.5

    Course was well taught and explained, and the depth of the content was just right. good examples. My only complaint was that it was a little dry.

Start FollowingSee all

We use cookies to enhance your experience on our website. Please read and confirm your agreement to our Privacy Policy and Terms and Conditions before continue to browse our website.

Read and Agreed