[New-bugs-announce] [issue7741] Allow multiple statements in code.InteractiveConsole.push

Kristján Valur Jónsson report at bugs.python.org
Tue Jan 19 15:52:03 CET 2010


New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:

The code.InteractiveConsole() is useful to emulate a python console.  However, any code currently "push"ed to it must be single statements.  This is because it passes the ´single´ symbol mode to the underlying compile function.
This patch allows the caller of InteractiveConsole.push to specify a different mode, e.g. ´exec´.  This is useful if one wants to paste entire code snippets into the console.  Without it, pasting the following:
'if True:\n  print 1\nprint 2' Won't run.  pushing such multiline code snippets with an additional 'exec' argument will allow it to work.
Patch included.

----------
components: Library (Lib)
files: code.patch
keywords: patch
messages: 98056
nosy: krisvale
severity: normal
status: open
title: Allow multiple statements in code.InteractiveConsole.push
type: feature request
versions: Python 2.7
Added file: http://bugs.python.org/file15950/code.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7741>
_______________________________________


More information about the New-bugs-announce mailing list