Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Using Python Class Constructors (Summary)

Now you know how Python class constructors allow you to instantiate classes, so you can create concrete and ready-to-use objects in your code. In Python, class constructors internally trigger the instantiation or construction process, which goes through instance creation and instance initialization. These steps are driven by the .__new__() and .__init__() special methods.

By learning about Python’s class constructors, the instantiation process, and the .__new__() and .__init__() methods, you can now manage how your custom classes construct new instances.

In this video course, you learned:

  • How Python’s instantiation process works internally
  • How your own .__init__() methods help you customize object initialization
  • How overriding the .__new__() method allows for custom object creation

Now you’re ready to take advantage of this knowledge to fine-tune your class constructors and take full control over instance creation and initialization in your object-oriented programming adventure with Python.

To learn more about the concepts in this course, you can check out:

Download

Sample Code (.zip)

2.2 KB

Download

Course Slides (.pdf)

4.9 MB

Younes Boukroun on March 18, 2023

The last 2 parts were hard to understand for me, I think giving some real life exemples could help.

Cenk T on March 25, 2023

totally confused me with tuples ..

Darren Jones RP Team on March 28, 2023

@Cenk T - can you give me a bit more information about the confusion you’re having, and hopefully I’ll be able to help out?

@Younes - Are you talking about the Single Instance and Emulating namedtuple sections?

Become a Member to join the conversation.