Comment

Comment by CloudYeller

I think multiple inheritance will always scare me. What order do the superclass inits run in? What happens if they do conflicting things? What if some superclasses call super().__init__ and others don't?

No thanks, I'll suffer through reading a few additional lines of:

class SomeBusinessyThing:

  def __init__(self, util, other_util):
    self._util = util
    self._other_util = other_util

  @classmethod
  def create(cls):
    return cls(util_module.Util(), other_module.Other())

  def calculate(self):
    source = self_other_util.get_source()
    return self._util.get_stuff(source)
vs

class SomeBusinessyThing(Utils, Other):

  def __init__(self, \*kwargs):
    # What does this do? No one knows
    super().__init__(self, \*kwargs)

  def calculate(self):
    source = self.get_source()
    return self.get_stuff(source)
parent CloudYeller 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton