Short if

Sylvain Thenault sylvain.thenault at nospam.logilab.fr
Wed Jul 7 14:32:33 CEST 2004


On Wed, 07 Jul 2004 12:04:11 +0000, Duncan Booth wrote:

> Thomas Lindgaard <thomas at it-snedkeren.BLACK_HOLE.dk> wrote in
> news:pan.2004.07.07.09.14.45.845781 at it-snedkeren.BLACK_HOLE.dk:
> 
>>   bool = false
>>   string = 'This is ' + (( bool ) ? 'true' : 'false')
> 
> You don't actually need a conditional expression here at all:
> 
> aBool = False
> string = 'This is ' + str(aBool)
> 
> sets string to 'This is False'

only with python >= 2.3, where the bool type has been introduced.

-- 
Sylvain Thénault                               LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org





More information about the Python-list mailing list