The difference in Python OOP between:

  • instance method
  • class method
  • static method

visually explained using ๐—บ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†_๐—ด๐—ฟ๐—ฎ๐—ฝ๐—ต:

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [S] 0 points 4 months ago (3 children)

Another common naming convention in C++ is using an underscore as prefix for member variables: int _memberVariable{123};

  • source
  • parent
  • hideshow 3 child comments
  • [โ€“] 1 point 4 months ago (2 children)

    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.

  • source
  • parent
  • hideshow 2 child comments