Comparing two class types in python

前端 未结 4 2154
时光取名叫无心
时光取名叫无心 2021-02-20 12:07

I have two classes defined in a module classes.py:

class ClassA(object):
    pass

class ClassB(object):
    pass

And in another m

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 12:39

    You're comparing the type of the class object, which are all of type 'type'.

    If you just want to compare the classes, compare them directly:

    print Class3 == Class4
    

提交回复
热议问题