The difference in Python OOP between:
- instance method
- class method
- static method
visually explained using 𝗺𝗲𝗺𝗼𝗿𝘆_𝗴𝗿𝗮𝗽𝗵:
You must log in or # to comment.
Coming from C++, I initially thought it aggravating that you have to go
self.everywhere when working with classes in Python. But I’ve conceded that it improves code-legibility, and now I’m goingthis->everywhere when I’m back in C++.Another common naming convention in C++ is using an underscore as prefix for member variables: int _memberVariable{123};
My personal convention in C++ was to use an
mprefix on member variables and agfor class variables.I guess in Python, I think of
_as equivalent toprotectedscope in C++ and__(double underscore) as equivalent toprivate. Not a perfect analogy, but it works for me.

