34

WTF python.... How the fuck are you an OOP language and unable to overload constructors...?

No method overloading... and they say JAVA is a shitty language.

Comments
  • 11
    ?????

    Because everything, including functions, classes, and metaclasses, is a first class item in Python. You literally can't have two functions that have the same name, but you can make a single function change its behavior with different sets of inputs by utilizing *args, **kwargs, and default values.
  • 4
    @tokumei Same name, but different signature.
    And these "workarounds" are.. well.. workarounds. Not something intuitive. But I guess quite nothing is intuitive in Py.

    Still better than Perl though. At least code does not look like a CBC-encrypted file
  • 3
    @irene separation of concerns for each method/constructor, clean code paradigms.

    Constructors to (#1) fill data structure either from data stream (which means lots of parsing) and (#2) to fill data structure manually, by supplying each field separately. #3 -- a copy-constructor

    Default values... well, that's just messy
  • 6
    @irene I get it... It does not mean I have to be happy about it. Hence the rant
  • 2
    (PHP Developers are here for fun)
  • 3
    maybe it's the limitation of dynamic typing ? but lately python implemented a static parameter type tho, never tried to use overloading in python using that.
  • 11
    Dont look at python as anything serious and you wont be disappointed. Learned it the hard way.
  • 4
    @irene its strange because this is one of the instances in which I can see what the op means but at the same time I still enjoy the language. Yes, we would normally use class methods, and even tho we can't have them have the same names I for one find it useful and easier to understand than the standard approach to other oop languages in which overloaded methods is a matter of different arguments.

    But I guess what op means is that it feels sorta hacky? At least to me it does. Is it in the docs? If i see this shit in the docs I will legit feel better about the hackyness.
  • 4
    If you think about it, it's obvious that class-based OOP in a dynamically typed language doesn't really make a whole lot of sense in the first place
  • 1
    @ganjaman is that a zed shaw refference?
  • 2
    @Krokoklemme yup, prototype based oop ftw!!
  • 2
    @AleCx04 prototypes would indeed have been a lot more appropriate lol

    They're actually one of the things i like about js, for example
  • 1
    @aureliagbrl seems logical; js has the same restriction.
  • 1
    @irene oooh i don't disagree at all really :>
  • 1
    @irene not disagreeing either, hence my comment ^^

    Was trying to point out that a lot of people just go "yay, classes" without ever thinking through what the implications are
  • 5
    Because inheritance is creation of devil who want to hide it’s sins in the parent.

    Use mixins.

    Don’t try to java in python.
  • 1
    Ikr!
    I've had the same issue.
    Only weird thing was: it worked until, all of a sudden, it didn't.
    It was working just fine until it suddenly said I too many arguments,taking one out, didn't have enough arguments.. Wth Python?
  • 2
    @irene ooh with that one I was just trolling. I have never been a real fan of oop and prefer a more procedural/functional approach to handling ma business. Which is why I am deeply in love with C and Lisp respectively.

    I don't get to use neither one at work tho :( ;___; i would kill for an opportunity to work with C. But being that my resume is more oriented towards web development with other languages i sometimes wonder if i will ever get a chance.
  • 1
    @AleCx04 functional code rocks.
  • 3
    Very few dynamically typed languages support overloading. Look at JavaScript, Lua, etc.
  • 2
    @irene That's exactly what I said
  • 1
    @AleCx04 ion know who that so yes
  • 2
    @irene "Very few dynamically typed languages support overloading"

    I then gave two examples. I dunno where the confusion came from, but I think we are in agreement.
  • 1
    I guess you missed __new__ and __init__ ?
Add Comment