What is the difference between __get__() and __getattr__() in Python? I come from a PHP background, where there is only __get(). When should I use which function?
I’ve been trying to figure this out for a while. I see plenty of questions like this one, asking about the difference between __getattr__() and __getattribute__(), though.
You will find detailed documentation for all those methods here.
Coming from PHP, you should first make yourself familiar with the Python object model. It’s much richer than PHP, so you should not try to map your PHP knowledge 1:1 to Python. If you want to develop PHP, use PHP. If you want to develop in Python, learn Python.
Coming back to your original question:
__getattr__is probably the function which does the same as the__getfunction in PHP.__get__in Python is used to implement descriptors. Details about descriptors can also be found in the documentation I mentioned above.