3/17 what's wrong with 'print a + " " + b'


#1

Hi,

as above - why should I use print a, b rather than print a + " " + b?
Is it more 'pythonic'?


#2

Using print a, b we don't have to concern over type. a can be one type, b another.

a = 5
b = 'five'
print a, b     # 5 five
print a + b    # TypeError: unsupported operand type(s) for +: 'int' and 'str'

So...

print str(a) + " " + b   # 5 five

#3

Nah, of course. I just forgot about types...
Thank bro.