4 ms·
"""I think his point, and it's a valid one, is that Python has practically re-invented private members with special underscore handling anyway -- just more half
by zephyrfalcon 9y ago
"""I think his point, and it's a valid one, is that Python has practically re-invented private members with special underscore handling anyway -- just more half-assed."""
It was added more as a kind of "stop gap" for people who complained about the lack of private/protected attributes. That's why it is indeed half-assed. :) And that's also why hardly anybody uses it, especially the double underscore thing.
- wvenable 9y agoUltimately I think the underscore itself is a hack. The need for protected/private members is so great that people will do it by convention anyway if the feature doesn't exist. If Python developers were truly serious about everything being public there would be no underscored members.
- pseudalopex 9y agoThe Python developers' position is that protected/private modifiers are really just convention too. Someone who wants to access a private member in Java can use reflection. We can't stop them, so why pretend?
- wvenable 9y agoBy definition protected/private modifiers aren't convention as they're part of the language itself. Convention is something that doesn't exist in the language. You cannot mark properties as private or protected in Python so the convention is that underscore means private or protected. There are no getters or setters in Java so the convention is to use a method with a get/set prefix. I would argue that such a common programming practice (enforced or not) should not be left to convention.