Overloading and? was <RE: Should I prefer an external database>
Steven Taschuk
staschuk at telusplanet.net
Wed Apr 23 15:53:21 EDT 2003
Quoth Andrew Dalke:
> Steven Taschuk
> > __and__ could be passed other as a callable which computes and
> > returns the second operand. Then the standard __and__ could be
> > def __and__(self, other):
> > if bool(self):
> > return self
> > return other()
>
> So a new idiom and new code (to generate a function from a set of
> unevaluated code), just to allow overriding booleans? Seems
> rather excessive to me.
Yes.
I do not (and did not) endorse this notion for __and__. I simply
do not agree with the previous claim that there's no way to
implement overloading and short-circuiting for the same operator.
No *good* way given how Python works now, perhaps.
> Gets pretty complicated with code like
>
> print value or sys._getframe().f_lineno
>
> since the function introduces a new frame.
A nice example.
--
Steven Taschuk staschuk at telusplanet.net
Receive them ignorant; dispatch them confused. (Weschler's Teaching Motto)
More information about the Python-list
mailing list