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


Groups > comp.lang.python > #93858 > unrolled thread

Re: Improve usage of Python 3

Started byTerry Reedy <tjreedy@udel.edu>
First post2015-07-15 05:33 -0400
Last post2015-07-15 05:33 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#93858 — Re: Improve usage of Python 3

FromTerry Reedy <tjreedy@udel.edu>
Date2015-07-15 05:33 -0400
SubjectRe: Improve usage of Python 3
Message-ID<mailman.533.1436952850.3674.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web