Kaydet (Commit) 52e85508 authored tarafından Ezio Melotti's avatar Ezio Melotti

Update section about dir() in the tutorial.

üst 89b03b0e
...@@ -288,16 +288,21 @@ defines. It returns a sorted list of strings:: ...@@ -288,16 +288,21 @@ defines. It returns a sorted list of strings::
>>> import fibo, sys >>> import fibo, sys
>>> dir(fibo) >>> dir(fibo)
['__name__', 'fib', 'fib2'] ['__name__', 'fib', 'fib2']
>>> dir(sys) >>> dir(sys) # doctest: +NORMALIZE_WHITESPACE
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__', ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__',
'__stdin__', '__stdout__', '_getframe', 'api_version', 'argv', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache',
'builtin_module_names', 'byteorder', 'callstats', 'copyright', '_current_frames', '_getframe', '_mercurial', '_xoptions', 'abiflags',
'displayhook', 'exc_info', 'excepthook', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_tracing',
'exec_prefix', 'executable', 'exit', 'getdefaultencoding', 'getdlopenflags', 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info',
'getrecursionlimit', 'getrefcount', 'hexversion', 'maxint', 'maxunicode', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info',
'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'float_repr_style', 'getcheckinterval', 'getdefaultencoding',
'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setdlopenflags', 'getdlopenflags', 'getfilesystemencoding', 'getobjects', 'getprofile',
'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval',
'gettotalrefcount', 'gettrace', 'hash_info', 'hexversion', 'int_info',
'intern', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path',
'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1',
'setcheckinterval', 'setdlopenflags', 'setprofile', 'setrecursionlimit',
'setswitchinterval', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion',
'version', 'version_info', 'warnoptions'] 'version', 'version_info', 'warnoptions']
Without arguments, :func:`dir` lists the names you have defined currently:: Without arguments, :func:`dir` lists the names you have defined currently::
...@@ -306,7 +311,7 @@ Without arguments, :func:`dir` lists the names you have defined currently:: ...@@ -306,7 +311,7 @@ Without arguments, :func:`dir` lists the names you have defined currently::
>>> import fibo >>> import fibo
>>> fib = fibo.fib >>> fib = fibo.fib
>>> dir() >>> dir()
['__builtins__', '__doc__', '__file__', '__name__', 'a', 'fib', 'fibo', 'sys'] ['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']
Note that it lists all types of names: variables, modules, functions, etc. Note that it lists all types of names: variables, modules, functions, etc.
...@@ -317,28 +322,31 @@ want a list of those, they are defined in the standard module ...@@ -317,28 +322,31 @@ want a list of those, they are defined in the standard module
:mod:`builtins`:: :mod:`builtins`::
>>> import builtins >>> import builtins
>>> dir(builtins) >>> dir(builtins) # doctest: +NORMALIZE_WHITESPACE
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException',
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'Buffer 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError',
Error', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'Environme 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError',
ntError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'Generato 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',
rExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexErr 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError',
or', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None',
'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'P 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError',
endingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', ' 'PendingDeprecationWarning', 'ReferenceError', 'ResourceWarning',
StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'Ta 'RuntimeError', 'RuntimeWarning', 'StopIteration', 'SyntaxError',
bError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'Unicod 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True',
eEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserW 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
arning', 'ValueError', 'Warning', 'ZeroDivisionError', '__build_class__', '__deb 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
ug__', '__doc__', '__import__', '__name__', '__package__', 'abs', 'all', 'any', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning',
'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'chr', 'classmethod', 'compile', ' 'ZeroDivisionError', '_', '__build_class__', '__debug__', '__doc__',
complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate '__import__', '__name__', '__package__', 'abs', 'all', 'any', 'ascii',
', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'bin', 'bool', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod',
'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir',
'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memory 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format',
view', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property' 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
, 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sort 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license',
ed', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip'] 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object',
'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr',
'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod',
'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
.. _tut-packages: .. _tut-packages:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment