What is Python?

Andrew Kuchling akuchlin at mems-exchange.org
Wed Sep 20 20:09:41 CEST 2000

tim at degree.ath.cx (Tim Hammerquist) writes:
> several Unix tools, accomplishes them very well.  I've noticed Pythoners
> like to stand on soapboxes and look down on regexps. ("A true Python
> solution wouldn't use regex's.")  Why look down on something so

Because people too often apply them to inappropriate tasks; the last
example I can recall was someone in c.l.p who was trying to use
regexes to filter out files with 'SCCS' in the path and .java at the
end.  The regex to do this is not easy to write and not clear.  Part
of the problem is that, like Prolog, you really need to understand the
underlying implementation to write regexes properly.  Making regexes
purely declarative might fix this, but even there .* behaves
counterintuitively.  An easy way of parsing text has not yet been
found, I think.
> What elemental functions aren't built-in?  I was under the impression
> that core modules were built-in, they simply exist in a separate
> namespace?

There's a __builtin__ module that you usually don't have to import,
but you can do things like:

import __builtin__
def open(...):
    ... do something different from the standard open...

Or this, to add a new built-in:

import __builtin__
def myfunc(): ...
__builtin__.myfunc = myfunc

The only serious package which actually adds a built-in function is
ZODB, I think; it adds a get_transaction() built-in function.  ZODB is
fancy enough, and provides such fundamental capabilities, that I think
it's justifiable in that case.


More information about the Python-list mailing list