Electron microscopy
 
PythonML
isinstance()
- Python Automation and Machine Learning for ICs -
- An Online Book -
Python Automation and Machine Learning for ICs                                                           http://www.globalsino.com/ICs/        


Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix

=================================================================================

Check instances using isinstance(): 1) We define three classes: Vehicle, Car, and Motorcycle. Car and Motorcycle are subclasses of Vehicle. However, we didn't define any attributes or methods for simplicity, so they are just empty classes. 2) We then instantiate objects of these classes: vehicle, car, and motorcycle. 3) The isinstance() function is used to check if an object is an instance of a specified class or its subclasses. We use it to check the type of each object we instantiated. code:    
         
Output:         
         

============================================

 

         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         

 

 

 

 

 



















































 

 

 

 

 

=================================================================================