First page Back Continue Last page Overview Image

dir()-Funktion

Mit der build-in-Funktion dir() kann man sich die in einem Modul definierten Namen ausgeben lassen.

>>> 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']

>>>

Ohne Argumente liefert dir() die definierten Namen

>>> import math

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

>>> dir()

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