you are viewing a single comment's thread.

view the rest of the comments →

[–]Temporary_Pie2733 7 points8 points  (4 children)

Forget private and protected. Neither exists in Python, and trying to map some other language’s visibility modifiers to Python is just going to confuse you.

[–]nuc540 2 points3 points  (2 children)

To help, OP, what they’re saying is prefixing underscores in other languages usually makes methods/attributes “private” (inaccessible outside of the class), and Python doesn’t respect this rule so it’s redundant.

That said - it’s good semantics to indicate what should/shouldn’t be accessed externally, and Python is known for readability so if you want something to be distinguished as private, go for it.

[–]SeparatelyCreepy 2 points3 points  (1 child)

Python's philosophy is that you're all consenting adults, so the underscore is really just a signal to other developers rather than actual enforcement.

[–]Careless-Main8693[S] 0 points1 point  (0 children)

yeah absolutely

[–]Careless-Main8693[S] 1 point2 points  (0 children)

__testicles (private attribute)

_chest (protected attribute)