Skip to content

Commit aec9e27

Browse files
committed
Update section about dir() in the tutorial.
1 parent 7dccde3 commit aec9e27

1 file changed

Lines changed: 33 additions & 26 deletions

File tree

Doc/tutorial/modules.rst

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,21 @@ defines. It returns a sorted list of strings::
282282
>>> import fibo, sys
283283
>>> dir(fibo)
284284
['__name__', 'fib', 'fib2']
285-
>>> dir(sys)
286-
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__',
287-
'__stdin__', '__stdout__', '_getframe', 'api_version', 'argv',
288-
'builtin_module_names', 'byteorder', 'callstats', 'copyright',
289-
'displayhook', 'exc_clear', 'exc_info', 'exc_type', 'excepthook',
290-
'exec_prefix', 'executable', 'exit', 'getdefaultencoding', 'getdlopenflags',
291-
'getrecursionlimit', 'getrefcount', 'hexversion', 'maxint', 'maxunicode',
292-
'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache',
293-
'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setdlopenflags',
294-
'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout',
285+
>>> dir(sys) # doctest: +NORMALIZE_WHITESPACE
286+
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__',
287+
'__stderr__', '__stdin__', '__stdout__', '_clear_type_cache',
288+
'_current_frames', '_getframe', '_mercurial', 'api_version', 'argv',
289+
'builtin_module_names', 'byteorder', 'call_tracing', 'callstats',
290+
'copyright', 'displayhook', 'dont_write_bytecode', 'exc_clear', 'exc_info',
291+
'exc_traceback', 'exc_type', 'exc_value', 'excepthook', 'exec_prefix',
292+
'executable', 'exit', 'flags', 'float_info', 'float_repr_style',
293+
'getcheckinterval', 'getdefaultencoding', 'getdlopenflags',
294+
'getfilesystemencoding', 'getobjects', 'getprofile', 'getrecursionlimit',
295+
'getrefcount', 'getsizeof', 'gettotalrefcount', 'gettrace', 'hexversion',
296+
'long_info', 'maxint', 'maxsize', 'maxunicode', 'meta_path', 'modules',
297+
'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1',
298+
'py3kwarning', 'setcheckinterval', 'setdlopenflags', 'setprofile',
299+
'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion',
295300
'version', 'version_info', 'warnoptions']
296301

297302
Without arguments, :func:`dir` lists the names you have defined currently::
@@ -300,7 +305,7 @@ Without arguments, :func:`dir` lists the names you have defined currently::
300305
>>> import fibo
301306
>>> fib = fibo.fib
302307
>>> dir()
303-
['__builtins__', '__doc__', '__file__', '__name__', 'a', 'fib', 'fibo', 'sys']
308+
['__builtins__', '__name__', '__package__', 'a', 'fib', 'fibo', 'sys']
304309

305310
Note that it lists all types of names: variables, modules, functions, etc.
306311

@@ -311,10 +316,11 @@ want a list of those, they are defined in the standard module
311316
:mod:`__builtin__`::
312317

313318
>>> import __builtin__
314-
>>> dir(__builtin__)
315-
['ArithmeticError', 'AssertionError', 'AttributeError', 'DeprecationWarning',
316-
'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False',
317-
'FloatingPointError', 'FutureWarning', 'IOError', 'ImportError',
319+
>>> dir(__builtin__) # doctest: +NORMALIZE_WHITESPACE
320+
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException',
321+
'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError',
322+
'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError',
323+
'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning',
318324
'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
319325
'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
320326
'NotImplementedError', 'OSError', 'OverflowError',
@@ -323,18 +329,19 @@ want a list of those, they are defined in the standard module
323329
'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True',
324330
'TypeError', 'UnboundLocalError', 'UnicodeDecodeError',
325331
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
326-
'UserWarning', 'ValueError', 'Warning', 'WindowsError',
332+
'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning',
327333
'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__',
328-
'__name__', 'abs', 'apply', 'basestring', 'bool', 'buffer',
329-
'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile',
330-
'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
331-
'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
332-
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex',
333-
'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
334-
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'memoryview',
335-
'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
336-
'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set',
337-
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
334+
'__name__', '__package__', 'abs', 'all', 'any', 'apply', 'basestring',
335+
'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr',
336+
'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright',
337+
'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval',
338+
'execfile', 'exit', 'file', 'filter', 'float', 'format', 'frozenset',
339+
'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input',
340+
'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license',
341+
'list', 'locals', 'long', 'map', 'max', 'memoryview', 'min', 'next',
342+
'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit',
343+
'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round',
344+
'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
338345
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
339346

340347

0 commit comments

Comments
 (0)