Stefan Ram wrote:
A postponed »if« can be found (x if a, otherwise y), but a
preceding »if« (if a, x, otherwise y) also is found often.
Yes, both forms occur in English. The point is that
Guido didn't just make the idea up, it was inspired
by natural language.
--
Greg
--
On Fri, Mar 17, 2017 at 10:45 AM, Stefan Ram wrote:
> Gregory Ewing writes:
>>wear(red_shirt if it_is_tuesday else green_shirt)
>
> Operators in Python usually are written with special
> symbols, not with words, so a word usually
Tobiah wrote:
To be fair, the proper comparison would be:
If it's Tuesday, I wear my red shirt, else my green one.
The Python analog of that would be
if it_is_tuesday:
wear(red_shirt)
else:
wear(green_shirt)
i.e. a statement rather than an expression. We're
William Mayor writes:
>> I think it would be nice to have a way of getting the 'true' value as
>> the return with an optional value if false. The desire comes about
>> when the thing I'm comparing is an element of a collection:
>>
>>drugs['choice'] if drugs['choice'] else 'pot'
>>
>>
On Thu, 16 Mar 2017 03:12:32 +, Stefan Ram wrote:
> The syntax
>
> a if c else b
>
> looks as if Guido made it intentionally ugly so that it will not be
> used?
>
> Being able to detect patterns that are in widespread use among
> programming languages enhances readability.
>
>
>
> I think it would be nice to have a way of getting the 'true'
> value as the return with an optional value if false. The desire
> comes about when the thing I'm comparing is an element of a collection:
>
>drugs['choice'] if drugs['choice'] else 'pot'
>
> Then I'm tempted to do:
>
>
On 03/16/2017 01:12 AM, Gregory Ewing wrote:
> Stefan Ram wrote:
>
>> a if c else b
>>
>> Guido has invented something totally new. Why?
>
> It's arguably closer to the way you would say such a
> thing in English.
>
> Consider the following sentences:
>
> "I wear my red shirt if it's
On 03/16/2017 01:12 AM, Gregory Ewing wrote:
> Stefan Ram wrote:
>
>> a if c else b
>>
>> Guido has invented something totally new. Why?
>
> It's arguably closer to the way you would say such a
> thing in English.
>
> Consider the following sentences:
>
> "I wear my red shirt if it's
Stefan Ram wrote:
a if c else b
Guido has invented something totally new. Why?
It's arguably closer to the way you would say such a
thing in English.
Consider the following sentences:
"I wear my red shirt if it's Tuesday, else my green one."
"I wear if it's Tuesday my red shirt, else my
Am 16.03.17 um 04:12 schrieb Stefan Ram:
The syntax
a if c else b
looks as if Guido made it intentionally ugly so that it will
not be used?
[...]
. But now Guido has invented something totally new. Why?
The rationale can be read in PEP 308:
10 matches
Mail list logo