Can the str.format()
method print boolean arguments without capitalized strings?
I cannot use str(myVar).lower()
as argument of format, because I want to preserve the case of the letters when myVar
is not a boolean.
Please don't post solutions with conditional checks of the values of the variable.
All I am interested is in the possibility of writing the following:
"Bla bla bla {}".format(myVar)
so that the output becomes "Bla bla bla true"
when myVar == True
and "Bla bla bla false"
when myVar == false
You could use an expression like this
str(myVar).lower() if type(myVar) is bool else myVar