3 ms·
IMO it's not too much of a wart to import it from the future in order to straddle 2.x/3.x. print() works, without a __future__ import, in Python 2.6. And 2.6 i
by ubernostrum 10y ago
IMO it's not too much of a wart to import it from the future in order to straddle 2.x/3.x.
print() works, without a __future__ import, in Python 2.6. And 2.6 is already well past end-of-life; anyone using a version of Python which doesn't support print-as-function without an import is someone whose timeline for a Python 3 upgrade is "never" -- they'd have moved to at least a later 2.x by now.
- wyldfire 10y agoprint() "works" but it's not a function in 2.6 without the import. It's still the print statement and those parens are just gratuitous. If you happen to pass multiple "function arguments" then what really happens is that you're providing a tuple to the print statement. This will cause the printout to have commas and parens which is not how the print function behaves. There are other subtle differences between the print statement and function (line-ending, etc). Example: https://gist.github.com/androm3da/dd257031eeaf3ff09d6654726a63f93f https://gist.github.com/androm3da/dd257031eeaf3ff09d6654726a...