Added Jython solution
Added abstract interface specification. (Motivation is in the abstract)
This commit is contained in:
parent
769523d18e
commit
4de28740f7
20
pep-0217.txt
20
pep-0217.txt
|
@ -20,6 +20,17 @@ Abstract
|
|||
Python, so users will have control over the output from the
|
||||
interactive interpreter.
|
||||
|
||||
Interface
|
||||
|
||||
The current Python solution has worked for many users, and this
|
||||
should not break it. Therefore, in the default configuration,
|
||||
nothing will change in the REPL loop. To change the way the
|
||||
interpreter prints interactively entered expressions, users
|
||||
will have to rebind sys.displayhook to a callable object.
|
||||
The result of calling this object with the result of the
|
||||
interactively entered expression should be print-able,
|
||||
and this is what will be printed on sys.stdout.
|
||||
|
||||
Solution
|
||||
|
||||
The bytecode PRINT_EXPR will call sys.displayhook(POP())
|
||||
|
@ -30,16 +41,13 @@ Solution
|
|||
def displayhook(o):
|
||||
if o is None:
|
||||
return
|
||||
__builtin__._ = None
|
||||
print `o`
|
||||
__builtin__._ = o
|
||||
print o
|
||||
|
||||
Jython Issues
|
||||
|
||||
The author knows too little about Jython, but it is very important
|
||||
to be compatible with it. displayhook will have to be added to sys,
|
||||
but since Jython works with Java bytecodes, the compiler would have
|
||||
to be changed too, or maybe not.
|
||||
Barry?
|
||||
The method Py.printResult will be similarily changed.
|
||||
|
||||
|
||||
Local Variables:
|
||||
|
|
Loading…
Reference in New Issue