Improve usage of Python 3

Terry Reedy tjreedy at udel.edu
Wed Jul 15 05:33:31 EDT 2015


On 7/14/2015 12:28 PM, Marcos wrote:
> Hi!
>
> Just like many, I want the projects in which I work on to move to Python 3.
>
> And incredibly, there are a few users on the same project who refuse to
> use python 3 simply because of the print statement.
>
> That has probably already been discussed, but since I actually couldn't
> find anything relevant about, I decided to ask here anyway.
>
> What are the changes of something like
>
> from __past__ import print_statement

0

> or to make both
>
> print

This already works, like any other name
 >>> print
<built-in function print>

To add to what Chris said, this means that print can be rebound just 
like any other name.  For example:

 >>> import builtins
 >>> builtins.print
<built-in function print>
 >>> def print(*args, **kwargs):
	kwargs['sep'] = '|'
	builtins.print(*args, **kwargs)

 >>> print(1,2,3)
1|2|3

> and
>
> print()
>
> work on Python 3 ?

-- 
Terry Jan Reedy




More information about the Python-list mailing list