Back to feed

Python Getters, Setters, and Properties

Real Python
Python Getters, Setters, and Properties

EDITOR BRIEF

Learn what getter and setter methods do in Python and why properties are usually the better choice. The article also explains when getters and setters still make sense.

INSIGHTS

Choosing how to expose an object's attributes can make your code easier to use and maintain. Try writing a property, then compare it with getter and setter methods.

CodeFriends courses that build on this story. Practice in the browser with nothing to install.

COMMENTS

0/40
0/2000

Loading comments…