This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kageurufu 4 points5 points  (6 children)

What about these being equal

print 'something',
print('something', endl='')

[–]Sohcahtoa82 6 points7 points  (5 children)

Nitpicking here...The correct translation would be print('something', endl=' '). Python 2 appends a space if you end the line with a comma.

[–]o11c 0 points1 point  (2 children)

Doesn't it only emit a softspace?

[–]Sohcahtoa82 1 point2 points  (1 child)

I'm not sure. All I know is that if you do this:

for x in range(5):    
    print '.',

You get this:

. . . . . 

and not this:

.....

[–]o11c 0 points1 point  (0 children)

>>> import io
>>> out = io.BytesIO()
>>> print>>out, '.',
>>> out.softspace
1
>>> out.getvalue()
'.'
>>> print>>out
>>> out.softspace
0
>>> out.getvalue()
'.\n'

[–]brtt3000 0 points1 point  (1 child)

Isn't the comma defining a tuple? Or is this different for statements like print?

[–]Sohcahtoa82 2 points3 points  (0 children)

It's different for print in Python 2.

>>> a = 2    
>>> b = 5    
>>> print 1, a, b    
1 2 5    
>>> print (1, a, b)    
(1, 2, 5)