views:

346

answers:

2

I see I can't do:

"%b %b" % (True, False)

in Python. I guessed %b for b(oolean). Is there something like this?

+4  A: 

Use

"%s %s" % (True, False)

if you want True False

because str(True) is 'True' and str(False) is 'False'.

or

"%i %i" % (True, False)

if you want 1 0

because int(True) is 1 and int(False) is 0.

Desintegr
+4  A: 
>>> print "%r, %r" % (True, False)
True, False

This is not specific to boolean values - %r calls the __repr__ method on the argument. %s (for str) should also work.

danben