python - Boolean to string with lowercase -


can str.format() method print boolean arguments without capitalized strings?

i cannot use str(myvar).lower() argument of format, because want preserve case of letters when myvar not boolean.

please don't post solutions conditional checks of values of variable.

all interested in possibility of writing following:

"bla bla bla {}".format(myvar) 

so output becomes "bla bla bla true" when myvar == true , "bla bla bla false" when myvar == false

you use expression this

str(myvar).lower() if type(myvar) bool else myvar 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -