[Pythonmac-SIG] Some test code

Fandekasp fandekasp at gmail.com
Thu Feb 3 09:24:24 CET 2011


If you have only 4 type of cards, it's even better to write a oneliner :

print card in ["Hearts", "Diamonds"] and "That car is red" or "That card is
> Black"


On 3 February 2011 07:48, Henning Hraban Ramm <hraban at fiee.net> wrote:

> Am 2011-02-03 um 05:45 schrieb Chris Rebert:
>
>
>  if (card == "Hearts" or card == "Diamonds"):
>>>    print "That card is Red"
>>>
>>> elif (card == "Spades" or card == "Clubs"):
>>>    print "That card is Black"
>>>
>>
>> Note that the parentheses are completely unnecessary and not idiomatic
>> style.
>>   if card == "Hearts" or card == "Diamonds":
>> is the normal way of writing compound conditions.
>>
>
> or even:
>
> if card in ('Hearts', 'Diamonds'):
>
>
> Greetlings from Lake Constance!
> Hraban
> ---
> http://www.fiee.net
> https://www.cacert.org (I'm an assurer)
>
>
>
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20110203/a5b2da23/attachment.html>


More information about the Pythonmac-SIG mailing list