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 8329191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:41:42+00:00 2026-06-09T01:41:42+00:00

I have two classes that inherit from the same base class but do not

  • 0

I have two classes that inherit from the same base class but do not want to play with each other, such are the young ones indeed.

class A() : 
  ...

class B(A) : 
  ...

class C(A) : 
  ...

b=B()
c=C()
c.method(b)

gives me a TypeError of c and b are not the same, what does python need to think that they are the same ? Is there some __SpecialThingIDontKnowAbout__ property/method one should implement or not ? Or is there some trick to class design that I’m missing

To be particular I am inheriting TreeDict() as follows :

class TNode(TreeDict):
 def __init__(self,*args,**kwargs) : 
  super(TNode, self).__init__(*args, **kwargs)

class LNode(TreeDict):
 def __init__(self,*args,**kwargs) : 
  super(LNode, self).__init__(*args, **kwargs)

TN = TNode(); TN.A = 1
LN = LNode(); LN.A = 1
LN.attach('TN',TN)

gives

Traceback (most recent call last):
  File "JSONE.py", line 430, in <module>
  LN.attach(TN)
TypeError: descriptor 'attach' requires a 'treedict.treedict.TreeDict' ...
object but received a 'type'

I do understand that the children are of ‘type’ and ‘treedict^3’ is required but how do I get the children to mimic this behaviour ?

EDIT :

Hmm… it started working now, not that I did anything different from what I can see in the undo/redo history (Thanks all)

  • 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-09T01:41:44+00:00Added an answer on June 9, 2026 at 1:41 am

    The problem is that the TreeDict type doesn’t allow subclassing. I found it in the treedict package. The TreeDict type itself is written in Cython. The culprit is this block of code in the attach() method (around line 1910 of treedict.pyx):

        if type(tree_or_key) is str:
            key = <str>tree_or_key
        elif type(tree_or_key) is TreeDict:
            if tree is not None:
                raise TypeError("Only one TreeDict instance can be given to attach.")
    
            tree = <TreeDict>tree_or_key
            key = None
        else:
            raise TypeError("`tree_or_key` must be either a string or TreeDict instance.")
    

    Change the elif type(tree_or_key) is TreeDict: line to elif isinstance(tree_or_key, TreeDict): and submit a patch to the project. You might want to check the rest of treedict.pyx for other occurrences of the same bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two case classes that inherit from an abstract base class. I want
I have two Parser classes that inherit from a base class, BaseParser. I want
I have two classes, one that inherits from the other. The base class is
I have a bas class called Media with two classes that inherit from it,
I have a class Derived that inherits directly from two base classes, Base1 and
I have two classes that refer to each other, but obviously the compiler complains.
I have two classes(Book,Software) that inherit from the Product class. these two classes have
I have two objects that are derived from same the base class. Lets say
If I have two classes that both implement an interface, but also inherit, do
I have two classes that my pages and controls inherit from. These two classes

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.