PEP 335: Overloadable Boolean Operators - Official Posting

Colin J. Williams cjw at sympatico.ca
Sat Sep 11 14:12:55 CEST 2004



Gerrit wrote:
> Colin J. Williams wrote:
> 
>>I understand that the intent, eventually, is that the basic types become 
>>classes.
>>
>>Would making Bool a class permit the achievement of these objectives?
>>
>>If Bool were a class, then subclasses could use __repr__ to provide 
>>alternative responses to False/True, such as No/Yes or Fail/OK.
> 
> 
> No, this has nothing to do with it. The representation is not the issue.
> The issue is that currently, 'a and b' returns either a or b. Suppose we
> have an array A = [a1, b1, c1], B = [a2, b2, c2], A and B will currently
> always return A. However, we may want it to return [a1 and a2, b1 and
> b2, c1 and c2]. That is what this PEP is about.

I misled with my comment about reprsentation.

The basic suggestion I was trying to make is that, with a subclass,
the expression 'A and B' could return almost whatever one wishes.

The use of __repr__ is a secondary benefit.

Colin W.
> 
> The lack op ability to subclass bool is something different. I don't
> know why that is.
> 
> regards,
> Gerrit.
> 



More information about the Python-list mailing list