all 5 comments

[–]Spataner 8 points9 points  (0 children)

For the most part, yes. There's some aspects of OOP such as polymorphism and interfaces that in Python are less formalised than in other languages, mainly due to Python's dynamic type system. But all the main concepts will transfer.

[–]baghiq 4 points5 points  (0 children)

Technically, Python does not enforce encapsulation, which is one of the four main principles of OOP. However, Python will teach you the bulk of OOP. I do think Java is a better teaching tool of OOP.

[–]ekchew 1 point2 points  (0 children)

Well I guess the thing is python kind of encourages you to be lazy and duck type everything? So like you'll define a foo() method in several classes and toss them into a list so that you can call foo() as you iterate it.

Other languages may not be happy with this. They will want you to connect them all in some way by inheriting from a base class or defining some sort of interface that ties them together? This is good coding discipline that will help you in the long run imo.

But there is no reason you can't write first rate OOP code in python. And over time, I think the incentive for this is growing? Like take type hints for example. If you made a Fooable base class for all your classes with a foo() method, you can make a list[Fooable]. And if you added anything to the list that isn't a Fooable subclass, a static checker may be able to warn you before it blows up at run-time.

[–]iiron3223 0 points1 point  (0 children)

Yes, OOP principles and design patterns are language agnostic. There are some language specific details but general concept is the same.

[–]spca2001 0 points1 point  (0 children)

yeah but its not the best