Title: from __future__ import print_function doesn't work (at interactive prompt)
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, irmen, pjac, zyasoft
Priority: low Keywords:

Created on 2013-01-19.13:21:33 by irmen, last changed 2014-06-19.06:14:31 by zyasoft.

msg7577 (view) Author: Irmen de Jong (irmen) Date: 2013-01-19.13:21:33
future's print_function doesn't work:

>>> from __future__ import print_function
>>> print("hello", end="test\n")
  File "<stdin>", line 1
    print("hello", end="test\n")
SyntaxError: no viable alternative at input '='

Expected :

>>> from __future__ import print_function
>>> print("hello", end="test\n")
msg7579 (view) Author: Irmen de Jong (irmen) Date: 2013-01-19.13:53:28
Note: this problem only occurs on the interactive prompt, when it is put in a module it works fine.
msg8110 (view) Author: Peter (pjac) Date: 2013-09-09.13:55:35
Confirming the print_function does not work at the Jython prompt (Mac OS X):

$ ~/jython2.7b1/jython
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52) 
[OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_24
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> print(1,2,3,4)
(1, 2, 3, 4)

Notice this is being interpreted as a print statement and a tuple.

Furthermore it does not seem to be working via a script which invokes doctests extracted from a file, specifically from Biopython has stopped working following changes in the test style to use print functions. e.g.

$ ~/jython2.7b1/jython
Skipping tests needing the following:
 - numpy
Running Tutorial doctests...
File "", line 150, in __main__.TutorialDocTestHolder.doctest_test_from_line_00601
Failed example:
    for index, letter in enumerate(my_seq):
        print(index, letter)
    0 G
    1 A
    2 T
    3 C
    4 G
    (0, 'G')
    (1, 'A')
    (2, 'T')
    (3, 'C')
    (4, 'G')

We have worked around this by modifying the print doctests:
msg8723 (view) Author: Jim Baker (zyasoft) Date: 2014-06-19.06:14:00
Interestingly, this works fine:

>>> from __future__ import print_function
>>> print(123)

But as reported, we still have this bug:

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

Whereas as CPython works like so:

>>> from __future__ import print_function
>>> print(1,2,3,4)
1 2 3 4
msg8724 (view) Author: Jim Baker (zyasoft) Date: 2014-06-19.06:14:31
Target beta 4
Date User Action Args
2014-06-19 06:14:31zyasoftsetmessages: + msg8724
2014-06-19 06:14:00zyasoftsetnosy: + zyasoft
messages: + msg8723
2013-09-09 13:55:35pjacsetnosy: + pjac
messages: + msg8110
2013-02-20 00:23:41fwierzbickisetpriority: low
nosy: + fwierzbicki
versions: + Jython 2.7, - 2.7a2
2013-01-19 13:53:29irmensetmessages: + msg7579
title: from __future__ import print_function doesn't work -> from __future__ import print_function doesn't work (at interactive prompt)
2013-01-19 13:21:33irmencreate