Answer the question
In order to leave comments, you need to log in
Is OOP in Python inferior to C#, C++, or Java?
I'm learning Python and I've discovered an amazing thing for myself. Python only has public and private! But what about protected?
I would like to know how much worse OOP is implemented in Python compared to the same pluses or Java? And are there any other nuances in Python related to OOP.
Answer the question
In order to leave comments, you need to log in
Private, protected and public in Python
The nuance is that this is all conditional.
It's a strange question, since in fact access modifiers have very little to do with encapsulation. Encapsulation should not be understood in such a way that it is generally a black box (although this is the ideal, we know that there are no ideals). Encapsulation is when code like this:
class Foo:
A = None
foo = Foo()
# some code here
if foo.A is not None:
# continue execute right way
else:
exit(1)
class Foo:
class PropertyUsedBeforeInit(Exception):
pass
_a = None
@property
def a(self):
if self._a is not None:
return self._a
else:
raise self.PropertyUsedBeforeInit()
@property.setter
def a(self, val):
self._a = val
try:
foo = Foo()
# just write ur code here
except Foo.PropertyUsedBeforeInit:
exit(1)
finally:
exit(0)
There is a point of view that C ++ and Java are not OOP languages at all, from the point of view of formal OOP.
Actually, they are just letters. You can at least write batch files in the OO style.
> worse than OOP implemented
Scripts, tests and frontend to Java/C++ are written in python. So there it is, how minimal it can be for entry.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question