Total Newbie here. Wondering if there is any way of editing script in the console after an error has been indicated. I am wanting to display script in the editor on a split page & modify the script in the console for learning purposes, but every time I make a mistake I have to delete everything I've typed rather than being able to just fix it. Thanks
To edit the last line typed into the console, hit the ^ button just above the = key at the upper right of the onscreen keyboard.
Thanks CCC. I didn't know about that. I am encountering other problems such as, if I copy my script from the editor to the console I can't get it to run, so are giving up on the console & playing around in the editor. I am going through a Python book & saving the example scripts in Pithonista so I can modify them as a tool for learning. However once modified, that's how they stay in the file & I have lost the original script I typed in. Have resorted to copying the original file, playing around with it in the editor, then deleting my modified version & pasting the original.
Any other alternatives???
When you run a script, you can look at variables in the console, run other functions, print things out in the console, etc. You can use the variable browser from the console.
You can also set breakpoints to use the visual debugger.
Another approach for debugging when you have an error:
import pdb pdb.pm()
Then you can inspect the state of variables, modify them, etc.
The console only lets you type one "line" at a time at the top level indent. You can type a complete def or class, but not multiple statements, so usually your cannot just paste something in from the editor, unless it is a top level def or class.
It is often just easier to make your updates to the editor file, and press play again
I find that I create
hack,.py, junk.py, scratch.pyall the time so that I can have one file that contains my modification/hacks while some other file contains the pristine unmodified original code that I started with. Every once in a while I actually make some useful improvement and then I select all and copy from
scratch.pyand select all and paste into the original. Life is easier when you get into the git workflow but this approach should be good enough for a start.
One idea would be to have a wrench script that saves the editor contents to a file with the same name and an incrementing number in the end. Then it would be easy to create ”checkpoints” while experimenting.