Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

Working With Python's .__dict__ Attribute (Summary)

You’ve learned a lot about Python’s .__dict__ attribute, which is a powerful tool for low-level and dynamic management of attributes in classes and instances. You learned that .__dict__ is a dictionary that maps attribute names to their values. You also delved into how .__dict__ works in classes, instances, functions, and other objects.

Understanding .__dict__ is key for Python developers, as it’s particularly useful for tasks such as debugging, data serialization, memoization, and metaprogramming.

Resources linked in this lesson:

In this video course, you’ve learned how to:

Locked learning resources

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

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

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

Unlock This Lesson

Already a member? Sign-In

00:00 Congratulations, you have reached the end of this course where you have lifted Python’s hood a little bit and snooped around looking at the .__dict__ attribute.

00:12 So what is it that you have learned? Well, you have learned what this attribute actually is, and that in fact it is just a dictionary and that it represents a namespace that maps attribute names to attribute values, and method names to method objects.

00:30 You also learned how to inspect this attribute and how to modify it. And given that this is just a dictionary, you can use standard dictionary functionality such as update() and del.

00:46 There are some additional resources that I would highly recommend you have a look at. Firstly, there is the written tutorial on which this video course is based and in that tutorial there are just more examples, and there is also some further detail.

01:01 There’s of course, Python classes. We dealt with classes, and if some of that went a bit too quickly, I didn’t spend too much time talking about the difference between instance attributes and class attributes, for example.

01:14 But there is a great tutorial here for you. Single and double underscore naming conventions. You worked with dunder methods and if that wasn’t entirely clear, then I would recommend you have a quick look at that tutorial.

01:30 And then lastly, Namespaces in Python, because the .__dict__ attribute actually represents a namespace.

01:39 So, there you have it. Thank you for watching. I hope you enjoyed taking this course as much as I have enjoyed making it. See you in the next one.

Become a Member to join the conversation.