[Tutor] Displaying Status on the Command Line
Steven D'Aprano
steve at pearwood.info
Thu Nov 8 11:08:06 EST 2018
On Thu, Nov 08, 2018 at 09:36:53AM -0600, Zachary Ware wrote:
> You can use any of the `print` function tricks above in Python 2 with
> the following boilerplate:
>
> from __future__ import print_function
>
> import sys
>
> _orig_print = print
>
> def print(*args, **kwargs):
> flush = kwargs.pop('flush', False)
> _orig_print(*args, **kwargs)
> if flush:
> file = kwargs.get('file', sys.stdout)
> file.flush()
Sorry, I don't understand that. Maybe its too early in the morning for
my brain, but given that you've imported the Python 3 print function
from the __future__ why do you need the customer wrapper?
from __future__ import print_function
alone should give you exactly the Python 3 print function, with all its
bells and whistles.
What have I missed?
--
Steve
More information about the Tutor
mailing list