Electron microscopy
 
if not hasattr/if hasattr (attribute)
- Python for Integrated Circuits -
- An Online Book -
Python for Integrated Circuits                                                                                   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

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

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

hasattr(object, name): hasattr() is called by getattr() to check to see if AttributeError is to be raised or not. The hasattr() method returns true if an object has the given named attribute and false if it does not.

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

Simple attribute demo: Code:
         Automatically Review, Scroll, Click Webpage and Its Link
Output:         
         Automatically Review, Scroll, Click Webpage and Its Link

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

Access the attributes in a class: Code:
         Automatically Review, Scroll, Click Webpage and Its Link
Output:         
         Automatically Review, Scroll, Click Webpage and Its Link

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

Access the local attribute externally: Code:
         Automatically Review, Scroll, Click Webpage and Its Link
Output:         
         Automatically Review, Scroll, Click Webpage and Its Link

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

Error: Code:
         Automatically Review, Scroll, Click Webpage and Its Link
Output:         
         Automatically Review, Scroll, Click Webpage and Its Link

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

"Useless" attribute: Code:
         Automatically Review, Scroll, Click Webpage and Its Link
Output:         
         Automatically Review, Scroll, Click Webpage and Its Link

         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         

 

 

 

 

 

 

 

 

 

 

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