sys.ps1 is not defined

Bug #512826 reported by Roald de Vries
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
New
Undecided
Unassigned

Bug Description

I found out from the python mailing list that to according to the Python specification, to be a valid Python shell, iPython has to implement sys.ps1 and sys.ps2.

Revision history for this message
Fernando Perez (fdo.perez) wrote :

And what problem does this cause in *actual practice*? IPython provides its own prompt mechanism, so it does not rely on the sys.ps{1,2} variables.

If you can post an actual problem caused by this please reopen.

Changed in ipython:
status: New → Invalid
Revision history for this message
Roald de Vries (ipython) wrote :

Clearly, becauses sys.ps{1,2} is part of the python definition, not every valid python program runs well on ipython. But, I admit, not many will have problems with this in practice.

A practical problem is this: I have a script that I want to use in 2 ways:
- for running from bash with command line arguments (subcommands); it executes the subcommands and exits
- for starting an interactive session in ipython

The script should check whether it is interactive or not, an in case it is, it should make available some functions and 'aliases'. The best (only?) way to find this out (for non-ipython-python) seems to be whether sys.ps{1,2} is defined or not.

I think it would be elegant if the ipython prompt mechanism could be made consistent with the sys.ps{1,2} mechanism.

Changed in ipython:
status: Invalid → New
Revision history for this message
Fernando Perez (fdo.perez) wrote : Re: [Bug 512826] Re: sys.ps1 is not defined

On Sun, May 23, 2010 at 5:38 AM, Roald de Vries <email address hidden> wrote:
> Clearly, becauses sys.ps{1,2} is part of the python definition, not
> every valid python program runs well on ipython. But, I admit, not many
> will have problems with this in practice.
>
> A practical problem is this: I have a script that I want to use in 2 ways:
> - for running from bash with command line arguments (subcommands); it executes the subcommands and exits
> - for starting an interactive session in ipython
>
> The script should check whether it is interactive or not, an in case it
> is, it should make available some functions and 'aliases'. The best
> (only?) way to find this out (for non-ipython-python) seems to be
> whether sys.ps{1,2} is defined or not.
>
> I think it would be elegant if the ipython prompt mechanism could be
> made consistent with the sys.ps{1,2} mechanism.
>

We've moved IPython development to github, so I've opened this as a
bug in the new tracker:

http://github.com/ipython/ipython/issues/issue/123

And with your new comments I agree with you, plus it's an easy fix.

Thanks for the report!

Cheers,

f

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.