How to check whether a variable is a class or not?

后端 未结 9 701
暖寄归人
暖寄归人 2020-11-28 19:14

I was wondering how to check whether a variable is a class (not an instance!) or not.

I\'ve tried to use the function isinstance(object, class_or_type_or_tuple

9条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 19:28

    class Foo: is called old style class and class X(object): is called new style class.

    Check this What is the difference between old style and new style classes in Python? . New style is recommended. Read about "unifying types and classes"

提交回复
热议问题