all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Multiple prompts when starting inferior Python
@ 2014-05-06 16:17 Joost Kremers
  2014-05-06 16:29 ` Andreas Röhler
  2014-05-07  3:27 ` Rusi
  0 siblings, 2 replies; 3+ messages in thread
From: Joost Kremers @ 2014-05-06 16:17 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

Whenever I start an interactive Python session in Emacs, I get four
empty prompts instead of one. That is, when I do `M-x run-python' (or
start from a Python file with `C-c C-z'), the *Python* buffer looks like
this:

,----
| Python 2.7.3 (default, Feb 27 2014, 19:58:35) 
| Type "copyright", "credits" or "license" for more information.
| 
| IPython 0.12.1 -- An enhanced Interactive Python.
| ?         -> Introduction and overview of IPython's features.
| %quickref -> Quick reference.
| help      -> Python's own help system.
| object?   -> Details about 'object', use 'object??' for extra details.
| 
| In [1]: 
| In [2]: 
| In [3]: 
| In [4]: 
| 
`----

I use elpy and IPython, but that doesn't make a difference. This is what
I get when running an interactive Python shell with `emacs -Q':

,----
| Python 2.7.3 (default, Feb 27 2014, 19:58:35) 
| [GCC 4.6.3] on linux2
| Type "help", "copyright", "credits" or "license" for more information.
| >>> >>> >>> >>> 
`----

Note the four `>>>'.

This is something that's been happening a while, and it's never really
bothered me. However, the other day someone on Reddit asked the same
question,[1] which prompted me to do some digging. I ran `run-python'
though the debugger and it seems that those prompts are caused by the
function `python-shell-send-setup-code', which sends the contents of the
variables listed in the variable `python-shell-setup-codes' to the
inferior python process when it's started. The default value of this
option is:

,----
| (python-shell-completion-setup-code python-ffap-setup-code python-eldoc-setup-code)
`----

Each of these variables contains some code which, when sent to the
inferior python process, results in a new prompt being displayed, even
though the actual command is not shown.

Is this something that should be considered a bug? Can it be avoided
somehow or should I simply live with it? (Which isn't very difficult, it
doesn't seem to affect anything.)

TIA


[1] http://www.reddit.com/r/emacs/comments/24fy1q/help_get_rid_of_multiple_inputs_when_running_a/


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Multiple prompts when starting inferior Python
  2014-05-06 16:17 Multiple prompts when starting inferior Python Joost Kremers
@ 2014-05-06 16:29 ` Andreas Röhler
  2014-05-07  3:27 ` Rusi
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Röhler @ 2014-05-06 16:29 UTC (permalink / raw)
  To: help-gnu-emacs

On 06.05.2014 18:17, Joost Kremers wrote:
> Hi,
>
> Whenever I start an interactive Python session in Emacs, I get four
> empty prompts instead of one. That is, when I do `M-x run-python' (or
> start from a Python file with `C-c C-z'), the *Python* buffer looks like
> this:
>
> ,----
> | Python 2.7.3 (default, Feb 27 2014, 19:58:35)
> | Type "copyright", "credits" or "license" for more information.
> |
> | IPython 0.12.1 -- An enhanced Interactive Python.
> | ?         -> Introduction and overview of IPython's features.
> | %quickref -> Quick reference.
> | help      -> Python's own help system.
> | object?   -> Details about 'object', use 'object??' for extra details.
> |
> | In [1]:
> | In [2]:
> | In [3]:
> | In [4]:
> |
> `----
>
> I use elpy and IPython, but that doesn't make a difference. This is what
> I get when running an interactive Python shell with `emacs -Q':
>
> ,----
> | Python 2.7.3 (default, Feb 27 2014, 19:58:35)
> | [GCC 4.6.3] on linux2
> | Type "help", "copyright", "credits" or "license" for more information.
> | >>> >>> >>> >>>
> `----
>
> Note the four `>>>'.
>
> This is something that's been happening a while, and it's never really
> bothered me. However, the other day someone on Reddit asked the same
> question,[1] which prompted me to do some digging. I ran `run-python'
> though the debugger and it seems that those prompts are caused by the
> function `python-shell-send-setup-code', which sends the contents of the
> variables listed in the variable `python-shell-setup-codes' to the
> inferior python process when it's started. The default value of this
> option is:
>
> ,----
> | (python-shell-completion-setup-code python-ffap-setup-code python-eldoc-setup-code)
> `----
>
> Each of these variables contains some code which, when sent to the
> inferior python process, results in a new prompt being displayed, even
> though the actual command is not shown.
>
> Is this something that should be considered a bug? Can it be avoided
> somehow or should I simply live with it? (Which isn't very difficult, it
> doesn't seem to affect anything.)
>
> TIA
>
>
> [1] http://www.reddit.com/r/emacs/comments/24fy1q/help_get_rid_of_multiple_inputs_when_running_a/
>
>


That's because some some setup-code is sent to the python-process connected to the buffer.
Basically a filter could wipe them out. OTOH it's does no harm.

With python-mode.el and M-x python RET you should not have this.

BTW with ipython, you will see the prompt-counter raised and starting with [5] or so - for the very same reason.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Multiple prompts when starting inferior Python
  2014-05-06 16:17 Multiple prompts when starting inferior Python Joost Kremers
  2014-05-06 16:29 ` Andreas Röhler
@ 2014-05-07  3:27 ` Rusi
  1 sibling, 0 replies; 3+ messages in thread
From: Rusi @ 2014-05-07  3:27 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday, May 6, 2014 9:47:55 PM UTC+5:30, Joost Kremers wrote:
> Hi,

> Whenever I start an interactive Python session in Emacs, I get four
> empty prompts instead of one. That is, when I do `M-x run-python' (or
> start from a Python file with `C-c C-z'), the *Python* buffer looks like
> this:

> ,----
> | Python 2.7.3 (default, Feb 27 2014, 19:58:35) 
> | Type "copyright", "credits" or "license" for more information.
> | 
> | IPython 0.12.1 -- An enhanced Interactive Python.
> | ?         -> Introduction and overview of IPython's features.
> | %quickref -> Quick reference.
> | help      -> Python's own help system.
> | object?   -> Details about 'object', use 'object??' for extra details.
> | 
> | In [1]: 
> | In [2]: 
> | In [3]: 
> | In [4]: 
> | 
> `----

> I use elpy and IPython, but that doesn't make a difference. This is what
> I get when running an interactive Python shell with `emacs -Q':

> ,----
> | Python 2.7.3 (default, Feb 27 2014, 19:58:35) 
> | [GCC 4.6.3] on linux2
> | Type "help", "copyright", "credits" or "license" for more information.
> `----

> Note the four `>>>'.

> This is something that's been happening a while, and it's never really
> bothered me. However, the other day someone on Reddit asked the same
> question,[1] which prompted me to do some digging. I ran `run-python'
> though the debugger and it seems that those prompts are caused by the
> function `python-shell-send-setup-code', which sends the contents of the
> variables listed in the variable `python-shell-setup-codes' to the
> inferior python process when it's started. The default value of this
> option is:

> ,----
> | (python-shell-completion-setup-code python-ffap-setup-code python-eldoc-setup-code)
> `----

> Each of these variables contains some code which, when sent to the
> inferior python process, results in a new prompt being displayed, even
> though the actual command is not shown.

> Is this something that should be considered a bug? Can it be avoided
> somehow or should I simply live with it? (Which isn't very difficult, it
> doesn't seem to affect anything.)



> [1] http://www.reddit.com/r/emacs/comments/24fy1q/help_get_rid_of_multiple_inputs_when_running_a/


Starting python as this
python -i -c 'import sys; sys.ps1=""'
Makes the >>> disappear.

Then you have to arrange to get it back!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-07  3:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-06 16:17 Multiple prompts when starting inferior Python Joost Kremers
2014-05-06 16:29 ` Andreas Röhler
2014-05-07  3:27 ` Rusi

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.