Python --Check type of values

Ref: [1] - Stackoverflow - What's the canonical way to check for type in python?

Exact type

if type(o) is str:
  print "this is a string"

Instance of type or instance of the subclass

if isinstance(o, str):
  print "this is a string or a instance of subclass of string"

There are more patterns in the reference to deal with more complex usecases.

Recommended Posts

Python --Check type of values
Check Python # type identity
Check OpenSSL version of python 2.6
Introduction of Python
Python nan check
[Python] Easy argument type check with dataclass
Check the behavior of destructor in Python
Python numeric type
Python: Tips-Swap values
python grammar check
Check the existence of the file with python
Basics of Python ①
Basics of python ①
Check the path of the Python imported module
Copy of python
[python] [meta] Is the type of python a type?
Python2 string type
Python # string type
[Python] Various combinations of strings and values
Introduction of Python
[python] Check the elements of the list all, any
[Python] How to use two types of type ()
Check the type of the variable you are using
[Python] Takes representative values ​​of multiple images [Numpy]
Check the date of the flag duty with Python
How to get dictionary type elements of Python 2.7
[Data science memorandum] Handling of missing values ​​[python]
[Python] Class type and usage of datetime module
[Python] Determine the type of iris with SVM
[Python] Operation of enumerate
List of python modules
Python callable type specification
Unification of Python environment
[python] behavior of argmax
Usage of Python locals ()
the zen of Python
Installation of Python 3.3 rc1
Swapping values in Python
# 4 [python] Basics of functions
Domain check with Python
Basic knowledge of Python
Sober trivia of python3
Summary of Python arguments
Basics of python: Output
Installation of matplotlib (Python 3.3.2)
Application of Python 3 vars
Various processing of Python
Check version with python
[Python] Chapter 02-06 <Supplement> Basics of Python programs (handling of numerical values)
Easy way to check the source of Python modules
(Python) Treat integer values as a set of flags
Summary of Python sort (list, dictionary type, Series, DataFrame)
Existence check of external command in Python (like `which`)
[Python] Type Error: Summary of error causes and remedies for'None Type'
How to write a list / dictionary type of Python3
Display a histogram of image brightness values in python
Python # How to check type and type for super beginners
Check the type and version of your Linux distribution
Check the asymptotic nature of the probability distribution in Python
[Python] Types of statistical values (features) and calculation methods
[Python] Correct usage of map