Even better: use the inspect.isclass
function.
>>> import inspect
>>> class X(object):
... pass
...
>>> inspect.isclass(X)
True
>>> x = X()
>>> isinstance(x, X)
True
>>> inspect.isclass(x)
False
More Related Contents:
- How to list all functions in a Python module?
- How can I get a list of all classes within current module in Python?
- How to list all functions in a module?
- How to dynamically load a Python class
- How to enumerate an object’s properties in Python? [duplicate]
- Can you use a string to instantiate a class?
- Python: changing methods and attributes at runtime
- Python decorator makes function forget that it belongs to a class
- Convert a python ‘type’ object to a string
- Finding the number of times characters from text1 occur in text2
- UnboundLocalError on local variable when reassigned after first use
- Breaking out of nested loops [duplicate]
- Getting a list of values from a list of dicts
- Reading/parsing Excel (xls) files with Python [closed]
- Truth value of a string in python
- Save classifier to disk in scikit-learn
- Using win32com with multithreading
- Integer division & modulo operation with negative operands in Python
- How to format seaborn/matplotlib axis tick labels from number to thousands or Millions? (125,436 to 125.4K)
- Does filehandle get closed automatically in Python after it goes out of scope?
- What is the hard recursion limit for Linux, Mac and Windows?
- Converting python objects for rpy2
- Embed picture in email
- How to access to ‘rect’ type element through Selenium-Python
- Why doesn’t django’s model.save() call full_clean()?
- List of IP addresses/hostnames from local network in Python
- Assignment Condition in Python While Loop
- Discrete legend in seaborn heatmap plot
- How to get more diagnostic output on a “no module named xyz” error?
- Accessing attribute from parent class inside child class