omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Editing Console

    Pythonista
    4
    6
    1688
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Alan
      Alan last edited by

      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

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by ccc

        To edit the last line typed into the console, hit the ^ button just above the = key at the upper right of the onscreen keyboard.

        1 Reply Last reply Reply Quote 0
        • Alan
          Alan last edited by

          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???
          Thanks Alan

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by JonB

            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

            1 Reply Last reply Reply Quote 0
            • ccc
              ccc last edited by ccc

              I find that I create hack,.py, junk.py, scratch.py all 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.py and 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.

              1 Reply Last reply Reply Quote 0
              • mikael
                mikael last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors