Hacker News new | past | comments | ask | show | jobs | submit login

It has optional arguments which make certain things a lot easier and make it much more consistent with the rest of the language.

sep is the separator between arguments, so you can do something like:

    >> print('a','b','c',sep='')
    abc
end is the value at the end of the line (useful, for example, if you want to print without a newline at the end).

file lets you specify a file to print to, so for example you can do file=sys.stderr to print to stderr instead of stdout.




All that is just syntactic sugar.

print "comma prevents a newline from being printed",

print >> sys.stderr, "Any file object can be used"

The change to a function is purely for consistency, not functionality.


Being part of __future__, is print() slated for release in 2.7 or is it strictly a 3.x feature?


In 2.7, print is still the print statement by default:

http://docs.python.org/2.7/library/functions.html#print


Strictly 3.0, because of backwards compatibility.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: