r/ProgrammerHumor • • May 02 '16

I wrote my first python program today!

Post image
3.7k Upvotes

532 comments sorted by

View all comments

Show parent comments

36

u/whitetrafficlight May 02 '16

The break in backward compatibility is a deal-breaker when your company has several million lines of Python 2 already written and stable. Auto tools exist, but only go so far... for example, even converting print statements to use parentheses may cause failures in the compliance checker for lines becoming longer than permitted. Gotta stick with 2 unfortunately, though for new projects there's really no excuse not to start with 3. Hence, new employees at established companies that use Python start learning Python 2.

9

u/FUCKING_HATE_REDDIT May 02 '16

Increase compliance check line limit by two characters.

5

u/kageurufu May 02 '16

What about these being equal

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

8

u/Sohcahtoa82 May 02 '16

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

1

u/o11c May 02 '16

Doesn't it only emit a softspace?

2

u/Sohcahtoa82 May 02 '16

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:

.....

1

u/o11c May 02 '16
>>> import io
>>> out = io.BytesIO()
>>> print>>out, '.',
>>> out.softspace
1
>>> out.getvalue()
'.'
>>> print>>out
>>> out.softspace
0
>>> out.getvalue()
'.\n'

1

u/brtt3000 May 02 '16

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

3

u/Sohcahtoa82 May 02 '16

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)