Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43185 > unrolled thread
| Started by | Nick Gnedin <ngnedin@gmail.com> |
|---|---|
| First post | 2013-04-09 10:33 -0500 |
| Last post | 2013-04-10 02:14 +1000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
standalone vs embedded interpreter Nick Gnedin <ngnedin@gmail.com> - 2013-04-09 10:33 -0500
Re: standalone vs embedded interpreter rusi <rustompmody@gmail.com> - 2013-04-09 08:52 -0700
Re: standalone vs embedded interpreter Chris Angelico <rosuav@gmail.com> - 2013-04-10 02:14 +1000
| From | Nick Gnedin <ngnedin@gmail.com> |
|---|---|
| Date | 2013-04-09 10:33 -0500 |
| Subject | standalone vs embedded interpreter |
| Message-ID | <mailman.355.1365521615.3114.python-list@python.org> |
Folks,
When simply I embed the interpreter:
#include "Python.h"
int main()
{
Py_Initialize();
PyRun_InteractiveLoop(stdin,"test");
Py_Finalize();
return 0;
}
I expect it to behave the same way as if I was running it as a
standalone program. On Windows this is indeed the case, but on my Linux
box (Python 3.3.1 (default, Apr 8 2013, 22:33:31) [GCC 4.1.2 20080704
(Red Hat 4.1.2-51)]) I get a different behavior in handling console
input. A standalone interpreter cycles though the input history when I
use up and down arrows - say, I type this code:
>>> 1
1
>>> a=4
>>> a
4
If I now press an <up> key in a standalone interpreter, I get 'a' placed
at the prompt (my previous command). However, in an embedded code I get
>>> ^[[A
put at the prompt - does anyone know what I am doing wrong?
Many thanks for any hint,
Nick
[toc] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-04-09 08:52 -0700 |
| Message-ID | <da180e15-b4a9-4d5b-98da-86fd672aec6e@lp1g2000pbb.googlegroups.com> |
| In reply to | #43185 |
On Apr 9, 8:33 pm, Nick Gnedin <ngne...@gmail.com> wrote:
> Folks,
>
> When simply I embed the interpreter:
>
> #include "Python.h"
>
> int main()
> {
> Py_Initialize();
> PyRun_InteractiveLoop(stdin,"test");
> Py_Finalize();
>
> return 0;
> }
>
> I expect it to behave the same way as if I was running it as a
> standalone program. On Windows this is indeed the case, but on my Linux
> box (Python 3.3.1 (default, Apr 8 2013, 22:33:31) [GCC 4.1.2 20080704
> (Red Hat 4.1.2-51)]) I get a different behavior in handling console
> input. A standalone interpreter cycles though the input history when I
> use up and down arrows - say, I type this code:
>
> >>> 1
> 1
> >>> a=4
> >>> a
> 4
>
> If I now press an <up> key in a standalone interpreter, I get 'a' placed
> at the prompt (my previous command). However, in an embedded code I get
>
> >>> ^[[A
>
> put at the prompt - does anyone know what I am doing wrong?
>
> Many thanks for any hint,
>
> Nick
You probably need readline
See http://docs.python.org/2/library/cmd.html#cmd.Cmd.cmdloop
[Also try Control-P COntrol-N for up and down arrow]
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-04-10 02:14 +1000 |
| Message-ID | <mailman.361.1365524048.3114.python-list@python.org> |
| In reply to | #43188 |
On Wed, Apr 10, 2013 at 1:52 AM, rusi <rustompmody@gmail.com> wrote: > You probably need readline > See http://docs.python.org/2/library/cmd.html#cmd.Cmd.cmdloop > [Also try Control-P COntrol-N for up and down arrow] Be aware that GNU readline is GPL, not LGPL. This may have consequences if you distribute your code. ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web