Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define sys.ps{1,2} #123

Closed
fperez opened this issue May 24, 2010 · 3 comments
Closed

Define sys.ps{1,2} #123

fperez opened this issue May 24, 2010 · 3 comments
Milestone

Comments

@fperez
Copy link
Member

fperez commented May 24, 2010

See https://bugs.launchpad.net/ipython/+bug/512826 for prior history.

Summary: we should define sys.ps{1,2} to make it easier for scripts to detect if they are being loaded interactively or not, and without ipython-specific checks.

@bfroehle
Copy link
Contributor

bfroehle commented May 8, 2012

I'm not sure that setting sys.ps1 will make it easier for scripts to detect if they are being loaded interactively. For example, consider

$ cat tst.py
import sys
try: print "sys.ps1=%r" % sys.ps1
except: print "no sys.ps1"

$ python -i tst.py
no sys.ps1
>>>

I think the author of the original issue might be better off passing some command line flags and parsing sys.argv.

Nonetheless it is true that execfile('tst.py') behaves differently

$ python
...
>>> execfile('tst.py')
sys.ps1='>>> '

and it'd be easy to set sys.ps1 in InteractiveShell.init_prompts or similar.

@fperez
Copy link
Member Author

fperez commented May 10, 2012

Did you mean to open a PR for this?

@bfroehle
Copy link
Contributor

Well, I'm not sure how I feel about it, so I haven't yet... but I will now, just to get some other commentary on the issue.

@fperez fperez closed this as completed in 5eb03bf May 10, 2012
jasongrout pushed a commit to jasongrout/ipython that referenced this issue May 10, 2012
Define generic sys.ps{1,2,3}, for use by scripts.

Closes ipython#123.
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Define generic sys.ps{1,2,3}, for use by scripts.

Closes ipython#123.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants