Overloading and? was <RE: Should I prefer an external database>

Bjorn Pettersen BPettersen at NAREX.com
Wed Apr 23 15:12:05 EDT 2003


> From: Andrew Dalke [mailto:adalke at mindspring.com] 
> 
> 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.

It occurred to me that C++ allows overloading of && (non c-s), while the
regular && is c-s.

Could it be that c-s is only useful in domains with exactly two elements
(true, false). I.e. don't worry about c-s for overloaded __and__ since
(a) the class you're overloading it on will probably not be limited to
two instances, and (b) even if it was, how would you know c-s is
desireable or even appropriate?

-- bjorn





More information about the Python-list mailing list