Use isinstance()
. Sample:
if isinstance(n, unicode):
# do this
elif isinstance(n, Node):
# do that
...
More Related Contents:
- What is the best (idiomatic) way to check the type of a Python variable? [duplicate]
- python typing module: Mixin
- Self-reference or forward-reference of type annotations in Python [duplicate]
- Is it Pythonic to check function argument types?
- Try/catch or validation for speed?
- My program works but Codeacademy does not acknowledge
- Split Strings into words with multiple word boundary delimiters
- Why does integer division yield a float instead of another integer?
- What do ellipsis […] mean in a list?
- Tkinter scrollbar for frame
- PYTHONPATH vs. sys.path
- Why is this python generator returning the same value everytime?
- python tracing a segmentation fault
- Subclassing Python dictionary to override __setitem__
- How can I do DNS lookups in Python, including referring to /etc/hosts?
- How to install PIP on Python 3.6?
- Process very large (>20GB) text file line by line
- Make distutils look for numpy header files in the correct place
- Pandas “Group By” Query on Large Data in HDFStore?
- Printing tuple with string formatting in Python
- Best way to join two large datasets in Pandas
- How to determine whether a column/variable is numeric or not in Pandas/NumPy?
- Removing Ttk Notebook Tab Dashed Line
- Python OpenCV2 (cv2) wrapper to get image size?
- Is it ok to skip “return None”?
- Multiple Unpacking Assignment in Python when you don’t know the sequence length
- How can I capture the stdout output of a child process?
- post request using python to asp.net page
- Comparing 2 lists consisting of dictionaries with unique keys in python
- How to run Debug server for Django project in PyCharm Community Edition?