Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is python __get__ method good for?

Tags:

python

What can __get__ achieve that can't be done with with a getter method on the owning object?

I can think of better separation of concerns but I guess there is more.

like image 603
reshefm Avatar asked Sep 11 '25 18:09

reshefm


1 Answers

It's used for descriptors. They are kind of like Python's getters/setters, and properties, but better. It's how Python implements the Uniform Access Principle. Python Descriptors

like image 167
Y.H Wong Avatar answered Sep 13 '25 07:09

Y.H Wong