sqlstring -- a library to build a SELECT statement
twic at urchin.earth.li
Thu Oct 20 23:20:09 CEST 2005
On Thu, 20 Oct 2005, grunar at gmail.com wrote:
> On this line of thought, what about the += operator? That might be more
> intuative than //. I could even use -= for not in.
You're going to have to explain to me how using an assignment operator for
something other than assignment is intuitive!
-1 on this one from me, i'm afraid.
Using 'in' would be good. It does require some truly puke-inducing
contortions, though; since 'in' calls __contains__ on the right-hand
operand, and that's likely to be a list, or some other type that's not
under your control, you have to cross your fingers and hope that whatever
it is implements __contains__ with equality tests with the probe object on
the left-hand side and the candidates on the right (as lists do, at least
in 2.4.1). then, you just have to make your table names do the right thing
when compared to strings.
It's a shame (sort of) that you can't define entirely new operators in
python. What we need is a __operate__(self, op, arg) special method, so
you could do:
>>> class Operable:
... def __operate__(self, op, arg):
... print "operating with", op, "on", arg
>>> o = Operable()
>>> o <~> "foo"
operating with <~> on foo
I'm sure that would do *wonders* for program readability :).
NOW ALL ASS-KICKING UNTIL THE END
More information about the Python-list