5 ms·
Nobody is switching to Python 3. If you go first you get all of the pain and no advantages (plus switching later isn't very hard anwyay). I would import unico
by justin_vanw 16y ago
Nobody is switching to Python 3. If you go first you get all of the pain and no advantages (plus switching later isn't very hard anwyay). I would import unicode_literals, division, and the print() function from __future__ and stick with 2.6.
- endtime 16y agoWhat are the benefits of print()?
- samdk 16y agoIt 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.
- gometro33 16y agoBeing part of __future__, is print() slated for release in 2.7 or is it strictly a 3.x feature?
- algorias 16y agoAll 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.
- babo 16y agofrom __future__ import print_function map(print, [1,2,3]) def test(*a, **b): print(*a, **b) test(12) with open('t.out', 'w') as f: test(12,13, sep='--', file=f)