- Extremely powerful pythonic feature.
- Features in Python that help understand other features.
- Everything in Python is an object, and introspection is to look at this objects in memory and provide information them(attributes & methods).
>>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__' [...snipped...]]
>>> import sys >>> >>> >>> type(sys) <type 'module'> >>> type(1) <type 'int'> >>> type()
>>> sys.__doc__ "This module provides access to some objects used [...snipped...]"
type, str, dir, help and all the rest of Python’s built−in functions are grouped into a special module called __builtin__.
Try to think of it like python interpreter calls import __builtin__ when you run a program.
Builtin methods are not keywords, their names can be over-ridden so do not use builtin method names for anything else.
>>> import __builtin__ >>> >>> __builtin__ <module '__builtin__' (built-in)> >>> >>> dir(__builtin__) ['ArithmeticError', 'AssertionError', 'AttributeError',[..snipped..] >>>