Life's better without builtins? (was: Life's better without braces)

Michael Hudson mwh21 at cam.ac.uk
Fri Feb 25 09:48:02 EST 2000


Niels Diepeveen <niels at endea.demon.nl> writes:

> Gerrit Holl schreef:
> > 
> > <quote name="Andrew M. Kuchling" date="951150482">
> > > [2] I occasionally think about this problem.  The setup: GvR was far
> > > too profligate in adding functions to bltinmodule.c that could have
> > > been written in pure Python instead.  So, how many built-in functions
> > > can you re-implement in pure Python?
> > 
> > These are possible:
> > 
> > abs, callable, chr, delattr, divmod,
> > execfile, filter, getattr, hex, input, int, isinstance, issubclass,
> > len, list, long, map, max, min, oct, range, raw_input, reduce, reload,
> > repr, setattr, tuple, vars.
> 
> Do you have some source code of this? I can't think of a way to do
> reload() or tuple().

Think module.__file__ & exec for reload.  Something like

def reload(module):
    exec open(module.__file__[:-1]).read() in module.__dict__
    return module

I agree about tuple though.

Cheers,
M.

-- 
very few people approach me in real life and insist on proving they are
drooling idiots.                         -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list