[Tutor] builltins

Scott Widney SWidney@ci.las-vegas.nv.us
Wed, 13 Mar 2002 14:36:04 -0800


> I am using python2.1.1 and when I type in 
> >>> dir(_builtins_) 
> in IDLE and hit return I get an error message saying that 
> builtins is not defined.
> I was expecting a list of the builtin modules as shown in 
> chapter 8 in learning Python.
> What did I do wrong?
> 

You should use two (2) underscores preceding and following 'builtins'. Take
a look:

PythonWin 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see
'Help/About PythonWin' for further copyright information.
>>> dir(__builtins__)
['ArithmeticError', 'AssertionError', 'AttributeError',
'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
'Exception', 'FloatingPointError', 'IOError', 'ImportError',
'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
'NotImplementedError', 'OSError', 'OverflowError', 'RuntimeError',
'RuntimeWarning', 'StandardError', 'SyntaxError', 'SyntaxWarning',
'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
'UnicodeError', 'UserWarning', 'ValueError', 'Warning', 'WindowsError',
'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__',
'abs', 'apply', 'buffer', 'callable', 'chr', 'cmp', 'coerce', 'compile',
'complex', 'copyright', 'credits', 'delattr', 'dir', 'divmod', 'eval',
'execfile', 'exit', 'filter', 'float', 'getattr', 'globals', 'hasattr',
'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance',
'issubclass', 'len', 'license', 'list', 'locals', 'long', 'map', 'max',
'min', 'oct', 'open', 'ord', 'pow', 'quit', 'range', 'raw_input', 'reduce',
'reload', 'repr', 'round', 'setattr', 'slice', 'str', 'tuple', 'type',
'unichr', 'unicode', 'vars', 'xrange', 'zip']
>>> 

Enjoy!

Scott