This is a question for people more experienced with Python, but everybody feel free to answer if you feel like you can provide something decent to the discussion.

Also feel free to explain why you feel that way and your experiences with Python and the paradigms.

  • Diplomjodler@lemmy.world
    link
    fedilink
    arrow-up
    12
    arrow-down
    2
    ·
    6 days ago

    I used to struggle with OOP because all the explanations I saw were in terms of metaphors of real world objects. Once i started seeing OOP as a way to better structure your code, it all fell into place. If you do anything marginally complex, OO is the way to go.

    • FizzyOrange@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      5 days ago

      I disagree. You can write a lot of high quality Python code (yeah it exists) before you need to use inheritance. If you’re reaching for inheritance as the solution to all complexity, GoF-style, then you’re doing it wrong.

      It’s an occasionally useful tool that has its place, not something you should instinctively reach for.

      • Diplomjodler@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        6 days ago

        I was talking about Python specifically. And no, of course it’s not a silver bullet. It’s a solution for structuring your code base in a way that lets you not lose track of what does what.

        • phutatorius@lemmy.zip
          link
          fedilink
          arrow-up
          1
          ·
          4 days ago

          It’s also a good way to structure your code to effectively model your problem domain.

          And there are also many cases where that’s not true, so use it where it makes sense and don’t use it where it doesn’t.

  • solrize@lemmy.ml
    link
    fedilink
    arrow-up
    7
    ·
    5 days ago

    You can write Python in an OOP style if you want to, and you sort of have to in the case of using certain libraries, but it’s mostly optional and imho rather ugly.

  • koala@programming.dev
    link
    fedilink
    arrow-up
    6
    ·
    5 days ago

    Well, it’s more procedural than object-oriented because it’s easier to avoid object-oriented programming than procedural code :D

    (Note: I wouldn’t call defining classes OOP until you start using inheritance. Overriding __str__ and stuff might count, but not a lot to me.)

    Personally, as time goes on, I use inheritance less.

  • Tja@programming.dev
    link
    fedilink
    arrow-up
    7
    ·
    6 days ago

    Any language can be procedural if you insist (maybe Haskell will fight you?), creating objects is a design choice to organize the code better. Any project beyond a few hundred lines of code should probably use objects.

    The language itself can be considered object oriented since it allows the typical OOP patterns.

    • Custodian6718@programming.devOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      6 days ago

      Obviously (almost) in any language code can be forcefully programmed the way you want, yes. But that is not how we normally code now is it? Usually languages & their community lean more towards certain paradigms than others.

      • Tja@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        6 days ago

        Depends also on what you use python for. If you build a whole piece of software, you will be using objects. But many teams use Java for the business logic and python as a scripting language to call some api, or automate a task. In those cases python will be used procedurally, as a nicer bash basically.

  • MoonMelon@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    ·
    5 days ago

    Used it a ton in the art departments of vfx and game dev. Im talking about the tools that make assets, not the game engine or a runtime scripting language. More like the stuff launching and running in Maya, or Houdini, or Substance, etc.

    Most of this is already highly OO, and there’s a lot of interaction with C++. Python is the perfect language for this. There’s a lot of rapid interation and gluing many different services and data together. Also you’re waiting on file IO or some massive scene graph update all the time so having the tools be slightly slower doesn’t matter. Also, at least in vfx, there’s mixed Linux/Windows/Mac and it’s great for that. ALSO art teams (unlike the programming team) have people who may not be super technical, and Python let’s them write tools and scripts more easily. They don’t even have to understand OO but you can say “copy this class template and implement these two methods” and they can write tools that “work” in the pipeline.

    It’s honestly a godsend. Before the industry settled on Python, every program had its own proprietary scripting language and some were quite limited. Their C++ APIs are all different, of course. So now everyone just ships with a Python interpreter, you manage launching each app so you can control PYTHONPATH and you’re golden.

  • thingsiplay@beehaw.org
    link
    fedilink
    arrow-up
    2
    ·
    6 days ago

    It supports both and depending on the situation its more procedural or more object oriented. Do you consider the standard library as part of the language and are you forced to use it? Then certainly the object oriented parts of the language would be forced to use and therefore it is object oriented. Or do you only evaluate the language and its features itself? In that case, Python supports object oriented programming with classes and objects, but you are not forced to use it.

    Are we talking about the language features itself or the produced programs with it in the real world?

    So regardless if you look at the language itself or the common standard library that most Python programs use, objects and classes are an part of the language. Even if you write simple procedural scripts, does not take away that Python itself is a more object oriented programming language.

  • grue@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    5 days ago

    I like writing Python in a relatively Functional way most of the time, with lots of list and dict comprehensions.

  • sugar_in_your_tea@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    ·
    6 days ago

    The language supports both, so it really depends on the user. The standard library doesn’t have a clear preference, and uses both approaches, along with functional style.

    So I’ll say both, and my preference is a hybrid of functional and procedural.