For Python2x If we use,
from __future__ import print_function
the print will become function which is previously the keyword
But practically,
How two of these are different ?
I can still use print the same way as I was using it when it was a keyword, then what difference does it make and how could it be more efficient than before ?
Here you can read some official documentation with examples and PEP3105 with more details.
As quick differences, there are several things which are very easy to do with print function (Python 3 or from __future__ import print_function) or at least very consistently:
No newline
print('Hello!', end='')
That was more complicated in python 2.
Print to stderr
import sys
print('ERROR!!!!!', file=sys.stderr)
In python 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With