For review: PEP 308 - If-then-else expression

Andrew McNamara andrewm at object-craft.com.au
Tue Feb 11 23:27:13 EST 2003


>>Piet van Oostrum wrote:
>>   ...
>> If b is a variable that takes only 0 and 1 as values then
>> 
>> b -> (x, y) is the same as
>> b -> [y, x]
>> 
>> because with boolean conditionals people are used to have the true clause
>> first. And we shouldn't change that.
>
>Argh -- I had missed that.  OK, then I don't like the proposal any
>more -- having to switch order of x and y depending on what
>parentheses you use would make the construct unusable IMHO, and,
>without the generality of being able to use it in the integer
>case, I don't think the usefulness is sufficient to warrant a
>new operator.  Pity:-(.

Half baked idea warning - what about:

    Boolean:

        c -> { True: x, False: y }

    Int:

        c -> { 0: x, 1: y, 2: z }

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/





More information about the Python-list mailing list