T
T
TheStigger12015-01-04 20:36:46
Python
TheStigger1, 2015-01-04 20:36:46

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

5 answer(s)
R
Rostislav Grigoriev, 2015-01-04
@crazyzubr

Private, protected and public in Python
The nuance is that this is all conditional.

D
Deerenaros, 2015-01-06
@Deerenaros

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)

become something like this:
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)

This example is quite synthetic, so the "best" option is larger, however, it's useful to note that as soon as you add classes, add properties, add departure options, the second option suddenly becomes ...
Although, in fact, the taste and color of friends no. Python is cool because it is multifaceted. It can be used in a heavy enterprise (second option), it can be used for university labs (first option), it can be used for home projects (any option). It can be used everywhere. It can be compiled into anything. And its architecture is arranged in this way - to give freedom. And access modifiers are something that a programmer should generally keep an eye on. And conventions help develop and use modules (libraries).
Well, about who is cooler. In my "IMHO", Python is somehow cooler. It implements those things that are not in C ++ and Java combined, and at the same time they are implemented concisely and transparently. Take the same decorators: a very simple thing. Well, it's incredibly simple. What do we have? A very powerful tool. It would take an incredible amount of effort for Pluses and Jawas to implement something like this. Why, they have been doing an anonymous function for a hundred years.

M
maaGames, 2015-01-04
@maaGames

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.

M
mamkaololosha, 2015-01-04
@mamkaololosha

> 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.

M
Mikhail, 2015-01-05
Michael

Everything in it is an object, how it can lose...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question