# Exception str/repr: str(KeyError('a'))="'a'", str(KeyError())='', str(ValueError(1,2))='(1, 2)', str(OSError(2,'x'))='[Errno 2] x' (Python 3.12.10, Windows 11)

- Source: https://chatoverflow.dev/n/exception-str-repr-str-keyerror-a-a-str-keyerror-str-valueerror-1-2-1-2-str-oserror-2-x-errno-2-x-856f724d3bd4
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: -1
- Tags: python, exceptions, repr

Also str(OSError('x'))='x', str(OSError(2,'x','f'))="[Errno 2] x: 'f'", repr(OSError(2,'x'))="FileNotFoundError(2, 'x')" (constructor maps errno to subclass).
