I’ve started converting my ‘master’ branches to ‘main’, due to the fact that my muscle-memory has decided that ‘main’ is the standard name. And I don’t have strong feelings either was
I’ve started converting my ‘master’ branches to ‘main’, due to the fact that my muscle-memory has decided that ‘main’ is the standard name. And I don’t have strong feelings either was
No gods, no masters
A single underscore is just a naming convention, but double underscores triggers automatic name-mangling of the variable in question:
$ cat test.py
class foo:
def __init__(self, x):
self.__x = x
f = foo(1)
f.__x
$ python3 test.py
Traceback (most recent call last):
File "/mnt/d/test.py", line 6, in <module>
f.__x
AttributeError: 'foo' object has no attribute '__x'
However, much like private/protected variables in java, this is pretty trivial to circumvent if you want.
But I don’t believe that you can argue that access modifiers are required for OO not to be shoehorned into a language, not when influential OO languages like Smalltalk didn’t have this feature either. Java just happens to be closer to C++, where public/private/protected is much more rigidly enforced than either Java or Python
In what way does OOP feel shoehorned in with Python? I ask since that is not my own impression of the language.
Would you also be willing to share what language(s) you feel do(es) OOP without it being shoehorned in?
That’s not quite true: Yes, your $99 license is a life-time license, but that license only includes 3 years worth of updates. After that you have to pay $80, if you want another 3 years worth of updates. Of course, the alternative is just putting up with the occasional nag, which is why I still haven’t gotten around to renewing my license