The difference in Python OOP between:
- instance method
- class method
- static method
visually explained using ๐บ๐ฒ๐บ๐ผ๐ฟ๐_๐ด๐ฟ๐ฎ๐ฝ๐ต:
The difference in Python OOP between:
visually explained using ๐บ๐ฒ๐บ๐ผ๐ฟ๐_๐ด๐ฟ๐ฎ๐ฝ๐ต:
My personal convention in C++ was to use an m prefix on member variables and a g for class variables.
I guess in Python, I think of _ as equivalent to protected scope in C++ and __ (double underscore) as equivalent to private. Not a perfect analogy, but it works for me.
@programming.dev
Welcome to the Python community on the programming.dev Lemmy instance!
November 2023
October 2023
July 2023
August 2023
September 2023
go to feed...
@programming.dev
Welcome to the Python community on the programming.dev Lemmy instance!
November 2023
October 2023
July 2023
August 2023
September 2023
go to feed...
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++.save