I’ve produced a minimal example. Basically:
«develop»:PIPER-ECHO:clu[master •]$ cat /tmp/ipythonvariable.py
try:
__IPYTHON__
except NameError:
IPYTHON = False
else:
IPYTHON = True
«develop»:PIPER-ECHO:clu[master •]$ ptipython -i /tmp/ipythonvariable.py
/usr/local/lib/python3.7/site-packages/IPython/core/interactiveshell.py:935: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn("Attempting to work in a virtualenv. If you encounter problems, please "
Python 3.7.6 (default, Dec 30 2019, 19:38:28)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: __IPYTHON__
Out[1]: True
In [2]: IPYTHON
Out[2]: False
In [3]: quit
«develop»:PIPER-ECHO:clu[master •]$

… in this case, the variable IPYTHON should evaluate to True, as it does when python -m IPython -i /tmp/ipythonvariable.py is run – because the special variable __IPYTHON__ is defined by IPython in the global namespace whenever it is running.
… It looks like ptpython runs the script named with “-i” before initializing the IPython environment, or somesuch – I briefly skimmed through the ptpython codebase but I’m not a REPL expert or an IPython guru or any of that, so this is just what I can surmise.
Either way it seems like a bug – the “-i” flag ought to behave as it does with vanilla IPython, n’est ce pas? I feel as though it ought. Yes.
I’ve produced a minimal example. Basically:
… in this case, the variable
IPYTHONshould evaluate toTrue, as it does whenpython -m IPython -i /tmp/ipythonvariable.pyis run – because the special variable__IPYTHON__is defined by IPython in the global namespace whenever it is running.… It looks like ptpython runs the script named with “-i” before initializing the IPython environment, or somesuch – I briefly skimmed through the ptpython codebase but I’m not a REPL expert or an IPython guru or any of that, so this is just what I can surmise.
Either way it seems like a bug – the “-i” flag ought to behave as it does with vanilla IPython, n’est ce pas? I feel as though it ought. Yes.