[Tutor] what.built-in

Kent Johnson kent37 at tds.net
Fri Sep 29 15:44:25 CEST 2006


jim stockford wrote:
> from
> http://docs.python.org/lib/built-in-funcs.html
> some functions are always available--the built-in functions.
> 
> (from elsewhere) everything in python is an object.
> 
> --------------------
> 
> hey, from abs() to zip() there's type() and super() and str()
> and setattr() and ... dir() and... they're the built-ins
> 
> my question: what.abs()  what.zip() etc.?
> 
> I think there must be a base object, a la java or Nextstep,
> that supports these functions. what is it?
> 
> maybe it's not practical, but it's driving me nuts anyway.
> thanks in advance.

They are attributes of the __builtins__ module which is searched as the 
last element of the name search path (local scope, nested scope(s), 
global (module) scope, __builtins__).

In [3]: __builtins__
Out[3]: <module '__builtin__' (

In [4]: dir(__builtins__)
Out[4]:
['ArithmeticError',
  'AssertionError',
...
  'ZeroDivisionError',
...
  '__debug__',
  '__doc__',
  '__import__',
  '__name__',
  '_ip',
  'abs',
  'all',
  'any',
  'apply',
  'basestring',
  'bool',
...
  'zip']

Kent



More information about the Tutor mailing list