Life's better without braces

Michael Hudson mwh21 at cam.ac.uk
Fri Feb 25 09:55:03 EST 2000
Gerrit Holl <gerrit.holl at pobox.com> writes:

> <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.
> 
> These aren't:
> 
> apply, buffer, coerce, compile, complex, dir, eval, exit, globals, hash,
> id, intern, locals, round, slice, type, xrange

To followup to a different bit of the thread about 30 seconds after
the last one, I think you can actually do quite a few of these.

`compile' would be a lot of work, but given the `new' module,
definitely possible (ask Jeremy Hylton!).
`dir' shouldn't be too hard given `type' & some knowledge of Python
internals.
`eval' can be done using `compile' & `exec'.
`globals' and `locals' can be done using the usual sys.exc_traceback
mucking around.
The builtin `exit' is just a string!

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