You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inject a flag variable into the global namespace to indicate to a script that it’s running inside bpython #795
Contrastingly, I just tried to programmatically figure out if my script was running in bpython or not, and the experience was… wanting. I tried the following three rubrics:
The first two methods work in the interactive REPL but don’t work in code loaded using the -i flag – presumably because it runs both before sys.stdout and friends have been wrapped, and before sys.argv has been mutated. The last method does seem to work, but it feels extremely janky and fragile and I don’t trust it to survive the next volley of bpython internals-refactoring.
So: can we get an officially-sanctioned method of determining that bpython is our host? That would be amazing, assuredly. It’s a great REPL, I use it every day – this’d make it even more betterer. Indeed!
Activity
supakeen commentedon Apr 11, 2020
Hey hey, what's the usecase for this? If there's a good one there's no problem in adding this.
Is using PYTHONSTARTUP a workaround for now?