AttributeError
Built-in ExceptionPython 2.0+Beginner
Raised when an attribute reference or assignment fails
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
# Triggering and catching AttributeError try: "hello".nonexistent except AttributeError as e: print(f"Caught AttributeError: {e}") print(f"Type: {type(e).__name__}")
AttributeError is raised when raised when an attribute reference or assignment fails. Always catch specific exceptions rather than bare except clauses.
Try in PlaygroundTags
exceptionerror-handlingcore