> Ah ha, thar's the disconnect.  Thanks for all the pointers, my def is
> now working.  Still don't understand the logic behind this design though.
> I mean why would any programming language have separate search or find
> functions, one for regex and and another for non-regex based pattern
> matching?
> 
> Aren't sed, awk, grep, and perl the reference implementations of search
> and replace?  They don't have non-regex functions, why does Python?
> Wouldn't it be a lot simpler to use a flag, like grep's '-f', to change
> the meaning of a search string to be literal?

And by this possibly destroying other modules code that rely on their
respective strings being that - and not patterns.
 
> My other gripe is with the kludgy object-oriented regex functions.
> Couldn't these be better implemented in-line?  Why should I, as a coder,
> have to 're.compile()' when all the reference languages do this at compile
> time, from a much more straightforward and easy to read in-line
> function...

You can do that already, no need to - the patterns are cached. Albeit the
cache might be limited in size. but code like

m = re.match(pattern, s)

is not considerably slower than

rex = re.compile(pattern)
m = rex.match(s)

Diez
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to