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 the default subtitles language 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.

Managing Attributes With Python's property() (Summary)

A property is a special type of class member that provides functionality that’s somewhere in between regular attributes and methods. Properties allow you to modify the implementation of instance attributes without changing the public API of the class. Being able to keep your APIs unchanged helps you avoid breaking code your users wrote on top of older versions of your classes.

Properties are the Pythonic way to create managed attributes in your classes. They have several use cases in real-world programming, making them a great addition to your skill set as a Python developer.

In this video course, you learned how to:

  • Create managed attributes with Python’s property()
  • Perform lazy attribute evaluation and provide computed attributes
  • Avoid setter and getter methods with properties
  • Create read-only, read-write, and write-only attributes
  • Create consistent and backwards-compatible APIs for your classes

If you’d like to learn more about the concepts covered in this course, then check out:

Download

Sample Code (.zip)

6.4 KB

Download

Course Slides (.pdf)

4.4 MB

Become a Member to join the conversation.