Closed GoogleCodeExporter closed 9 years ago
Background:
>>> dis.disco(compile("s='test'; s", "<main>", "single"))
1 0 LOAD_CONST 0 ('test')
3 STORE_NAME 0 (s)
6 LOAD_NAME 0 (s)
9 PRINT_EXPR
10 LOAD_CONST 1 (None)
13 RETURN_VALUE
>>> dis.disco(compile("s='test'; print s", "<main>", "single"))
1 0 LOAD_CONST 0 ('test')
3 STORE_NAME 0 (s)
6 LOAD_NAME 0 (s)
9 PRINT_ITEM
10 PRINT_NEWLINE
11 LOAD_CONST 1 (None)
14 RETURN_VALUE
>>> n = None
>>> n
>>> print n
None
>>> n = "test"
>>> n
'test'
>>> print n
test
Original comment by dwhall...@gmail.com
on 28 Jul 2010 at 8:12
There are 6 distinct cases among None and string objects. Here is a table of
what gets printed in these conditions. expr = from an interactive expression
where just the object is given. print = when the print statement prints an
object. nest = when an object is nested inside another object (such as inside
a Tuple, Dict or List).
====== ====== ======
None String
====== ====== ======
expr 'str'
print None str
nest None 'str'
====== ====== ======
Original comment by dwhall...@gmail.com
on 5 Aug 2010 at 4:16
r563
- Fixed argument in call to obj_print in PRINT_ITEM and PRINT_EXPR bytecode in
interp.c
- Renamed "marshall" argument to "is_escaped" in string print functions for
clarity.
- Escaped the single quote character in string.c for correctness.
- Added is_nested argument to obj_print to indicate when objects to print are
nested inside another object.
- Removed single quotes when printing object instances.
There is no way to make a system test to check the output of the print command.
Tested manually on ipm and compared to CPython.
Test suite passes, too.
Mainlined directly.
Original comment by dwhall...@gmail.com
on 5 Aug 2010 at 4:23
Original issue reported on code.google.com by
dwhall...@gmail.com
on 28 Jul 2010 at 7:08