overload operator()?
Andrew Dalke
adalke at mindspring.com
Mon Dec 16 15:48:19 EST 2002
Chris Liechti wrote:
> that would be __call__ but some people say that overloading operators leads
> to confusing code...
I have a regexp engine with ideas based on Greg Ewing's
Plex. It lets you do regexp-style parsing of complex data files.
It builds up the regexp from parts. This makes it easier to
construct valid regexps. Suppose you have
from Martel import *
s = Re("a*b*")
t = Re("c*")
Many would say that
u = s.add(t)
-or-
u = add(s, t)
is more confusing than
u = s + t
Given that the result, u, is equivalent to
Re("a*b*c*")
Ie, exactly like adding two strings together.
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list