First page Back Continue Last page Overview Graphics

dir() Function

With an argument, returns a list of valid attributes for that object.

>>> dir(math)

['__doc__', '__file__', '__name__', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log', 'log10', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']

>>>

Without arguments, return the list of names in the current local scope.

>>> import math

>>> col = ["red","green","blue"]

>>> dir()

['__builtins__', '__doc__', '__name__', 'col', 'math']