- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How I can check if A is superclass of B in Python?
We have the classes A and B defined as follows −
class A(object): pass class B(A): pass
Example
A can be proved to be a super class of B in two ways as follows
class A(object):pass class B(A):pass print issubclass(B, A) # Here we use the issubclass() method to check if B is subclass of A print B.__bases__ # Here we check the base classes or super classes of B
Output
This gives the output
True (<class '__main__.A'>,)
- Related Articles
- How can I check if a JavaScript function is defined?
- How can I check if a JavaScript variable is function type?
- Check if a number can be expressed as a^b in Python
- How do I check if a Python variable exists?
- How I can check a Python module version at runtime?
- How do I check if raw input is integer in Python 3?
- How I can check if class attribute was defined or derived in given class in Python?
- How can I check whether a variable is defined in JavaScript?
- How can I tell if a string repeats itself in Python?
- Check if N can be represented as sum of integers chosen from set {A, B} in Python
- How do I check if a string has alphabets or numbers in Python?
- How to check if type of a variable is string in Python?
- How to check if a string can be converted to float in Python?
- How to check if a list is empty in Python?
- How to check if a string is alphanumeric in Python?

Advertisements