Terry J. Reedy added the comment:

I have in mind the idea of enhancing run module options.  In particular, I 
think there should be a "Run in console" option ("python -i -m <file>".  
However I do not understand exactly what you would want.

I believe you could now write an extension that would add 'pgzrun' to the Run 
menu and define a function bound to that entry that would call subprocess with 
"python -m pgzero <script>".  Error tracebacks (and print() output, but games 
should not do such) would appear in the console menu instead of Idle's Shell.  
You could add '-i' to the invocation for post-mortem investigation.

Idle *simulates* running a file with "python -i -m <script>".  What it actually 
does (on Windows) is "pythonw -m .../idlelib/run.py".  The editor contents are 
compiled in the Idle process. The code must be complete at this time.  For 
tracebacks to work properly, it must be the same as displayed in the editor, so 
adding an import line is a bad idea. 

If both the process invocation and compile work, the code object is sent to the 
process and exec'ed in a pseudo-main namespace.  Output to stdout/err is sent 
back to Shell.  The only interpreter option I see here is run a different 
version of python and run.py (not trivial).

The user process should import site.py and if present, sitecustomize  and maybe 
a 'usercustomize'.  I am not familiar with these but you could investigate.

I do not see the point of an absolute zero boilerplate requirement. Kids manage 
with "from turtle import *" and anyone should be able to deal with "from pgz 
import *".  Avoiding even that given people a wrong impression of what a proper 
python file looks like and creates trouble that I see as unnecessary.

Since the solution to your problem seems to be a custom extension, patch, or 
use of the site module, I am inclined to close this.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24718>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to