Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. Object oriented programming in Python be like:

Object oriented programming in Python be like:

Scheduled Pinned Locked Moved Programmer Humor
49 Posts 28 Posters 1 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F [email protected]

    Functional programming fixes the problem by simply not making it OO anymore, and while I'm personally a big fan of the paradigm there are situations where an OO approach is preferable (or even only to conform to a project's existing way of doing things).

    kogasa@programming.devK This user is from outside of this forum
    kogasa@programming.devK This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #40

    What I described isn't necessarily functional. This is just a principle for ensuring objects represent clear and well-defined contracts. The idea is that to mutate something, you should own it; that means interfaces / public APIs, which can be called externally, should take immutable arguments. You can still mutate instance members internally because those are owned by the instance. If mutation is really necessary between two objects then it should be coordinated by an object owning them both.

    1 Reply Last reply
    0
    • D [email protected]

      I'll add that 100% of the above is understood by the compiler. Unlike Python or JavaScript where you don't know how bad you have it until the program is already running.

      L This user is from outside of this forum
      L This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #41

      At least python has a decent runtime typing system

      JS's type system feels like what you'd get by giving a monkey access to unlimited cocaine and a computer

      1 Reply Last reply
      7
      • J [email protected]

        Oh, you assigned a method to a variable before calling it? Congratulations, this is now undefined.

        P This user is from outside of this forum
        P This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #42

        Yes. There's no telling what this is. this could be anything. We tried to keep track of this, but no one knows when this will change.

        J 1 Reply Last reply
        3
        • P [email protected]

          Yes. There's no telling what this is. this could be anything. We tried to keep track of this, but no one knows when this will change.

          J This user is from outside of this forum
          J This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #43

          I used to be with this, but then they changed what this was.

          Now what I'm with isn't this, and what's this seems weird and scary to me.

          This'll happen to you!

          1 Reply Last reply
          5
          • G [email protected]

            that's because anyone who develops oop in Python is mentally ill.

            Python is a scripting language, not to be confused with an actual programming language. Like everything else in development over the last decade, newbs are just shoehorning whatever is hot into the language because nobody is stopping them.

            D This user is from outside of this forum
            D This user is from outside of this forum
            [email protected]
            wrote on last edited by [email protected]
            #44

            that’s because anyone who develops oop in Python is mentally ill.

            Hard disagree there. I would argue that most "multi-paradigm" languages converge on the same features, given enough time to iterate. It's not necessarily about hot-sauce. I honestly think its about utility and meeting your userbase where their heads are.

            G 1 Reply Last reply
            0
            • F [email protected]

              Not like C# is all that much better. So much garbage in the fundamentals just because it was done that way at the start and "they can't change it now". The best example is the IList interface.

              Theoretically this interface exposes both index-based access and collection-like modifications and as such would be perfect in a function if you need those two features on a type. In reality you can't use it as a function parameter because half the official types implementing IList aren't modifiable and throw a runtime error. E.g Arrays

              S This user is from outside of this forum
              S This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #45

              Embrace the holy light of Dart

              1 Reply Last reply
              0
              • D [email protected]

                that’s because anyone who develops oop in Python is mentally ill.

                Hard disagree there. I would argue that most "multi-paradigm" languages converge on the same features, given enough time to iterate. It's not necessarily about hot-sauce. I honestly think its about utility and meeting your userbase where their heads are.

                G This user is from outside of this forum
                G This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #46

                I honestly think its about utility and meeting your userbase where their heads are.

                then the Python userbase must have their heads shoved up their ass.

                1 Reply Last reply
                1
                • M [email protected]

                  Now my brain wants to relate Java somehow to beancounters.

                  P This user is from outside of this forum
                  P This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #47

                  Well it is owned by Oracle now

                  1 Reply Last reply
                  0
                  • F [email protected]

                    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?

                    A This user is from outside of this forum
                    A This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #48

                    I was looking to see if there are equivalents to Java's private and protected members, and it looks like Python's answer to that is just throw one or two underscores in front of things to do that. And it doesn't really do anything, more of just a naming convention. To me that feels like a basic OO structure that is shoehorned into Python.

                    F 1 Reply Last reply
                    0
                    • A [email protected]

                      I was looking to see if there are equivalents to Java's private and protected members, and it looks like Python's answer to that is just throw one or two underscores in front of things to do that. And it doesn't really do anything, more of just a naming convention. To me that feels like a basic OO structure that is shoehorned into Python.

                      F This user is from outside of this forum
                      F This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #49

                      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

                      1 Reply Last reply
                      1
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups