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 refer to our video player troubleshooting guide for assistance.

Getters and Setters in Python (Summary)

Now you know what getter and setter methods are and where they come from. These methods allow access and mutation of attributes while avoiding API changes. However, they’re not so popular in Python because of the existence of properties. Properties allow you to add behavior to your attributes while avoiding breaking changes in your APIs.

Even though properties are the Pythonic way to replace traditional getters and setters, properties can have some practical drawbacks that you can overcome with getters and setters.

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

  • Write getter and setter methods in Python
  • Use Python properties to replace getter and setter methods
  • Use Python tools, like descriptors, to replace getters and setters
  • Decide on when setter and getter methods can be the right tool for the job

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

Download

Sample Code (.zip)

3.2 KB
Download

Course Slides (.pdf)

4.9 MB

Become a Member to join the conversation.