executing python code

Alex Greif
2006-08-02
2012-09-14
  • Alex Greif
    Alex Greif
    2006-08-02

    Hi,
    I have a file open in PyPE. How can I run this code? I did not find a menu entry for executing code.

    Alex.

     
    • Josiah Carlson
      Josiah Carlson
      2006-08-02

      It depends on what kind of code it is. If it is Python, then you can save it as a .py file, and run it in a console via 'python filename.py' . PyPE also has a 'built-in' command shell, that you can access via "File -> New Command Shell".

      If you want an interactive console, you can use "File -> New Python Shell", and you can paste any code you want to run.

      If you feel like modifying the current document, click on the "macro" tab, which will offer you options for manipulating macros, which are primarily for modifying the currently open document programmatically.

      If it is another language, like perhaps Pyrex, C, C++, etc., you are going to need to compile the source as necessary.

       
    • arol
      arol
      2006-08-20

      Another text editor useful for coding Python scripts is NewEdit. One of its nifty features is that the draft python code in the editing window can be run just by hitting a button in the toolbar. The output (including errors) is shown in a subwindow. It would really be great if a similar feature is added to PyPE, as tis would allow a quicker way of spotting errors in the code.

       
      • Josiah Carlson
        Josiah Carlson
        2006-08-20

        One can always write a macro for it.

        I've added a few extra features to make writing that particular macro easier (stripping shared indent from selected text, setting clipboard text, etc.), and will be including it in the /macros/samples directory with the next release.