Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8745865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:06:16+00:00 2026-06-13T12:06:16+00:00

I have a class that inherits from 2 other classes. These are the base

  • 0

I have a class that inherits from 2 other classes. These are the base classes:

class FirstBase(object):
      def __init__(self, detail_text=desc, backed_object=backed_object,
                   window=window, droppable_zone_obj=droppable_zone_obj,
                   bound_zone_obj=bound_zone_object,
                   on_drag_opacity=on_drag_opacity):
          # bla bla bla

class SecondBase(object):
      def __init__(self, size, texture, desc, backed_object, window):
          # bla bla bla

And this is the child:

class Child(FirstBase, SecondBase):
       """ this contructor doesnt work
       def __init__(self, **kwargs):
          # PROBLEM HERE
          #super(Child, self).__init__(**kwargs)
       """
       #have to do it this TERRIBLE WAY
       def __init__(self, size=(0,0), texture=None, desc="", backed_object=None,
                    window=None, droppable_zone_obj=[], bound_zone_object=[],
                    on_drag_opacity=1.0):
          FirstBase.__init__(self, detail_text=desc, backed_object=backed_object,
                             window=window, droppable_zone_obj=droppable_zone_obj,
                             bound_zone_obj=bound_zone_object,
                             on_drag_opacity=on_drag_opacity)
          SecondBase.__init__(self, size, texture, desc, backed_object, window)

I wanted to solve it all nicely with **kwargs but when I call the first commented out constructor I get TypeError: __init__() got an unexpected keyword argument 'size'.

Any ideas how I can make it work with **kwargs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:06:16+00:00Added an answer on June 13, 2026 at 12:06 pm

    Your problem is that you only tried to use super in the child class.

    If you use super in the base classes too, then this will work. Each constructor will “eat” the keyword arguments it takes and not pass them up to the next constructor. When the constructor for object is called, if there are any keyword arguments left over it will raise an exception.

    class FirstBase(object):
        def __init__(self, detail_text=None, backed_object=None,
                     window=None, droppable_zone_obj=None,
                     bound_zone_obj=None, on_drag_opacity=None, **kwargs):
            super(FirstBase, self).__init__(**kwargs)
    
    class SecondBase(object):
        def __init__(self, size=(0,0), texture=None, desc="",
                     backed_object=None, window=None, **kwargs):
            super(SecondBase, self).__init__(**kwargs)
    
    class Child(FirstBase, SecondBase):
        def __init__(self, **kwargs):
            super(Child, self).__init__(**kwargs)
    

    As you can see, it works, except when you pass a bogus keyword argument:

    >>> Child()
    <__main__.Child object at 0x7f4aef413bd0>
    >>> Child(detail_text="abc")
    <__main__.Child object at 0x7f4aef413cd0>
    >>> Child(bogus_kw=123)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "test.py", line 14, in __init__
        super(Child, self).__init__(**kwargs)
      File "test.py", line 5, in __init__
        super(FirstBase, self).__init__(**kwargs)
      File "test.py", line 10, in __init__
        super(SecondBase, self).__init__(**kwargs)
    TypeError: object.__init__() takes no parameters
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes, one that inherits from the other. The base class is
I have a base class that three classes inherit from. Whenever these child classes
I have a class that inherits from a base class (this contains a lot
Example: I have an class that inherits from UIImageView. An object creates an instance
Suppose I have a class Baz that inherits from classes Foo and Bar ,
I have a base class, SpecialClass . Lots of other classes inherit from it,
I have two classes that inherit from the same base class but do not
I have a set of classes that inherit from the same base class and
I have a class that inherits from a generic dictionary as follows: Class myClass
I have a class that inherits from Page, called APage. public abstract class APage:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.