[Python-Dev] Why is there still a PRINT_EXPR opcode in Python 3? (original) (raw)
Guido van Rossum guido at python.org
Mon Jan 5 20:48:26 CET 2009
- Previous message: [Python-Dev] Why is there still a PRINT_EXPR opcode in Python 3?
- Next message: [Python-Dev] Small question about BufferedRandom spec
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Jan 5, 2009 at 4:25 AM, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote:
On Mon, Jan 5, 2009 at 00:53, Benjamin Peterson wrote:
On Sun, Jan 4, 2009 at 5:36 PM, <skip at pobox.com> wrote:
>> Since print is now a builtin function why is there still a PRINTEXPR >> opcode? Benjamin> I believe it's used in the interactive interpreter to display Benjamin> the repr of an expression. Wouldn't it make more sense for the interactive interpreter to call print(repr(expr)) I'm not sure about the reasoning for keeping PRINTEXPR alive. When I look at the code of PyRunInteractiveOne, it seems it should be possible to kill it off. How would you display multiple lines, like: for x in range(3): ... x, x * x ... (0, 0) (1, 1) (2, 4) if 1: ... "some line" ... "another line" ... 'some line' 'another line' OTOH this seems an obscure feature. "for" and "if" are statements after all.
That feature may be obscure but should not be killed. It'd be a bit tricky to remove the PRINT_EXPR call since it doesn't invoke the print() function -- it invokes something more basic that goes through sys.displayhook. I don't care about the opcode, but the semantics should remain unchanged. Keeping the opcode is probably easiest.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Why is there still a PRINT_EXPR opcode in Python 3?
- Next message: [Python-Dev] Small question about BufferedRandom spec
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]