[Patches] [ python-Patches-1633807 ] from __future__ import print_function

SourceForge.net noreply at sourceforge.net
Wed Jan 17 16:58:31 CET 2007


Patches item #1633807, was opened at 2007-01-12 08:13
Message generated for change (Comment added) made by twouters
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1633807&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Anthony Baxter (anthonybaxter)
Assigned to: Nobody/Anonymous (nobody)
Summary: from __future__ import print_function

Initial Comment:
This was done partly as a learning exercise, partly just as a vague idea that might prove to be practical (chatting with Neal at the time, but all blame is with me, not him!)

The following adds 'from __future__ import print_function' to 2.x. When this is enabled, 'print' is no longer a statement. Combined with copying bltinmodule.c:builtin_print() from the p3yk trunk, this should give some compatibility options for 2.6 <-> 3.0

Note that for some reason I don't fully understand, this doesn't work in interactive mode. For some reason, in interactive mode, the parser flags get reset for each line. Wah. 

----------------------------------------------------------------------

>Comment By: Thomas Wouters (twouters)
Date: 2007-01-17 16:58

Message:
Logged In: YES 
user_id=34209
Originator: NO

You seem to have '#if 0'ed-out some code related to the with/as-statement
warnings; I suggest just removing them. Since you're in this code now, it
might make sense to provide a commented out warning about the use of the
print statement, so we won't have to figure it out later (in Python 2.9 or
when we add -Wp3yk.)

It needs a test, and probably a doc change somewhere.


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-01-17 16:24

Message:
Logged In: YES 
user_id=6380
Originator: NO

I don't think we need to do anything special for exec, as the exec(s,
locals, globals) syntax is already (still :-) supported in 2.x with
identical semantics as in 3.0.

except E as V *syntax* can go in without a future stmt; and (only when
that syntax is used) it should also enforce the new semantics (V must be a
simple name and is deleted at the end of the except clause).

I think Anthony's patch is a great idea, but I'll refrain from reviewing
it.  I'd say "just do it". :-)

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-01-17 08:42

Message:
Logged In: YES 
user_id=33168
Originator: NO

Guido, this is the patch I was talking about wrt supporting a print
function in 2.6.  exec could get similar treatment.  You mentioned in mail
that things like except E as V: can go in without a future stmt.  I agree.

----------------------------------------------------------------------

Comment By: Anthony Baxter (anthonybaxter)
Date: 2007-01-12 08:31

Message:
Logged In: YES 
user_id=29957
Originator: YES

Updated version of patch - fixes interactive mode, adds builtins.print

File Added: print_function.patch

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1633807&group_id=5470


More information about the Patches mailing list