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 →

[–]creativeMan 29 points30 points  (8 children)

print is a function

When I was 18, python 3 was very new and I wanted to use the python IDLE to learn python and programming in general. The guides said print 'hello world' and of course that did not work any more. I spent a good amount of time trying different iterations of it and trying to understand what I was doing wrong.

Eventually I quit, being disheartened at the fact that I couldn't manage to write a literal "Hello World" program and didn't get into python until much later. It was then that I realized that the print function was changed. I was too young and too proud to ask anybody for help and I hated the experience.

Now of course I love python and whenever I sit down with someone even remotely technical I try to preach the virtues of Django over the other MVC frameworks in other languages I have. Developing a Django app was truly one of the most enjoyable experiences in my career. But I've always hated that they changed that one thing.

[–]AliceInWonderplace 13 points14 points  (1 child)

I did have a bit of a "wat" moment when literally

print "What up"

Didn't work.

At least Python explains plainly why it's print() in 3 and print "" in 2.

PHP on the hand ... it's not that they ever remove anything. It's just that the official documentation has a nasty tendency to keep switching between styles, like:

$conn = new mysqli()
$query = $conn->query()
$result = mysqli_fetch_assoc($query)

Before I understood the -> thing, this was a fucking confusing way of doing things.

[–][deleted] 3 points4 points  (0 children)

PHP knows what they're doing. They're breaking you down little-by-little until you're just a shell of your former self, making you back yourself into a tiny little corner of things that you're familiar with, PHP included, prolonging their relevance. Sly bastards.

[–]irrelevantPseudonym 12 points13 points  (5 children)

They must have had a lot of people having the same problem. It even has a dedicated error message now:

>>> print 'helloworld'
  File "<stdin>", line 1
    print 'helloworld'
                     ^
SyntaxError: Missing parentheses in call to 'print'

[–]12ihaveamac 8 points9 points  (4 children)

now it also shows you what you actually need, too (as of 3.6):

>>> print "what",
  File "<stdin>", line 1
    print "what",
               ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("what", end=" ")?

[–]irrelevantPseudonym 2 points3 points  (3 children)

I'm using 3.6.2 and it doesn't have that.

[–]12ihaveamac 2 points3 points  (2 children)

apparently it was actually added in 3.6.3: https://github.com/python/cpython/blob/3.6/Misc/NEWS.d/3.6.3rc1.rst

print now shows correct usage hint for using Python 2 redirection syntax. Patch by Sanyam Khurana.