Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93858

Re: Improve usage of Python 3

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Improve usage of Python 3
Date 2015-07-15 05:33 -0400
References <55A538C9.5050509@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.533.1436952850.3674.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Improve usage of Python 3 Terry Reedy <tjreedy@udel.edu> - 2015-07-15 05:33 -0400

csiph-web