Using 'Or'

Alister alister.ware at ntlworld.com
Sat Jan 16 17:47:46 EST 2016


On 16/01/16 21:53, Steven D'Aprano wrote:
> On Sun, 17 Jan 2016 01:06 am, Alister wrote:
>
>> Conditional operators (or and not == etc.) need to be used in a test
>
> Technically, that is incorrect.
yes but the op is confused in his usage enough at present
>
>> how else would you expect you print statement to be able to decided
>> which to print?
>
>
> default = "I like Brussels sprouts."
> message = random.choice(["", "I like boiled cabbage."])
> print( message or default )
>
>
>
I hope I never see production code like that




More information about the Python-list mailing list