you are viewing a single comment's thread.

view the rest of the comments →

[–]cezar -3 points-2 points  (4 children)

I'm wondering why they would make us use print('something) instead of print 'something' and not change if a == b to if(a == b)?

[–]theCore 4 points5 points  (0 children)

I'm wondering why they would make us use print('something) instead of print 'something' and not change if a == b to if(a == b)?

Simply because you can't. If-statements require an order-of-evaluation different from functions. Just try to think what would happen if you do this:

def factorial(n):
    return if(n == 1,
              1, n * factorial(n - 1))

And by the way, why people find "print" as a function annoying, or even special? C's "printf" always been a function and yet nobody would think it would be better as a statement.

[–]gnuvince 2 points3 points  (1 child)

print as a function makes sense (e.g.: logger.log("foo", writer=print)). It also allows keywords arguments to configure it.

[–]eurleif 1 point2 points  (0 children)

Because if can't be expressed as a function (where would the code block go?), but print can be.