john doe
0
Q:

python multiclass inheritance with inputs

class a:
    def __init__(self):
        print("Hello")

class c:
    def __init__(self, text):
        print(text)
        
class d(a,c):
   def__init__(self,text):
       a.__init__(self)
       c.__init__(self,text)
1
# Example of multiple inheritance
# I recommend to avoid it, because it's too complex to be relyed on.

class Thing(object):
    def func(self):
        print("Function ran from class Thing()")

class OtherThing(object):
    def otherfunc(self):
        print("Function ran from class OtherThing()")
      
class NewThing(Thing, OtherThing):
    pass

some_object = NewThing()

some_object.func()
some_object.otherfunc()
-1

New to Communities?

Join the community