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

Andrew Dalke adalke at mindspring.com
Wed Apr 23 18:58:18 CEST 2003


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.

Gets pretty complicated with code like

print value or sys._getframe().f_lineno

since the function introduces a new frame.

OTOH, this could lead to an easy 'if/else' expression function.
And generically speaking, adding code blocks like this leads
towards Smalltalk and Ruby.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list