Could embeded Python echo evaluation?
tim_one at email.msn.com
Sun Feb 20 14:14:29 EST 2000
[Kim Jeong Ju]
> When you run Python in console mode, you can see result string after
> evaluation without any explicit print command.
> >>> 3 + 4
> >>> dir
> <built-in function dir>
> But embeded Python doesn't show its result string.
> You should specify 'print' command to see the result as in
> console mode.
> Why this behavior happens?
Python used to (many years ago) automagically display non-None expression
results in both interactive and batch modes. There were many complaints
about this behavior in batch mode, especially from people chaining methods
for side effects; e.g.,
where each method of myPoint returns "self". This is a pretty common style.
> Are there any way to let Python echoing result automatically
> in embeded version?
No, not anymore. The function com_expr_stmt in compile.c compiles different
code depending on whether you're in batch or interactive mode. In the batch
case it compiles code to throw away the expression result; in the latter
case it generates the PRINT_EXPR opcode that implements the interactive-mode
More information about the Python-list