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
Post a Comment