[issue45297] Improve the IDLE shell save command

2022-03-20 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Here is another example of a newbie caught by this:

https://discuss.python.org/t/syntax-error-in-python-3-10-when-running-on-terminal/14462

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45297] Improve the IDLE shell save command

2021-09-26 Thread Steven D'Aprano


New submission from Steven D'Aprano :

See this question on Discuss:

https://discuss.python.org/t/what-is-this-syntax-i-dont-know-how-to-fix-it/10844

It seems that IDLE allows you to save the shell output, complete with welcome 
message and prompts, as a .py file, and then reopen it and attempt to run it, 
which obviously fails. When it does fail, it is confusing.

Suggested enhancements:

- When saving the complete shell session, save it to a text file, not .py. That 
would be useful for anyone wanting a full record of the interpreter session.

- When saving the shell session as a .py file, strip out the welcome message, 
the prompts, and any output, leaving only what will hopefully be runnable code.

I don't know what sort of UI this should have. Two different menu commands? A 
checkbox in the Save dialog?

My thoughts are that the heuristic to reconstruct runnable code from the 
interpreter session may not be foolproof, but better than nothing. Something 
like the doctest rules might work reasonably well.

- strip the welcome message;

- any line (or block) starting with the prompt >>> that is followed by a 
traceback should be thrown out;

- any other text not starting with the prompt >>> is interpreter output and 
should be thrown out;

- you should be left with just blocks starting with the prompt, so remove the 
prompt, adjust the indents, and hopefully you're left with valid runnable code.

--
assignee: terry.reedy
components: IDLE
messages: 402686
nosy: steven.daprano, terry.reedy
priority: normal
severity: normal
status: open
title: Improve the IDLE shell save command
type: enhancement
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com