Giter VIP home page Giter VIP logo

python-script-rerunner's Introduction

Python advanced REPL

This is an interactive python script that can run python files, and preserve the global state between runs. It is helpful for when the initialization step of your code (like loading a large csv or asset) takes a long time, which would make rerunning the script over and over again directly a bit unpractical.

A Jupyter notebook seems to be the accepted solution for this kind of problem, but I don't like it because:

  • Your can't work on your code as a collection of python files forming a software module
  • You can't edit the code with an editor of your choice unless that editor has a Jupyter Notebook extension
    • The Jupyter Notebook extension is not guaranteed to work all the time. Maybe if it had worked for me today, I wouldn't have made this ...
  • It is overkill for something that can be achieved quite simply

How to use

Download the main.py and put it somewhere.

Now run it like python main.py. You should get an interactive REPL-like command line interface. Type help and hit enter to see all the commands you have.

An example use:

D:\Some\Directory>python main.py
Started. Enter 'help' for help
> cd testing

changed current directory to : D:\Projects\Python\ComputeGraph\testing
Files:
        algorithm.py, init.py

> run algorithm.py

running algorithm.py ...
an error occured when trying to execute the command:

name 'x' is not defined

Note that this will run arbitrary python code, with exec. Also, try to avoid running code that will ask for input, make sure you are doing that if __name__ == "__main__": thing.

> run init.py

running init.py ...

done

> run algorithm.py

running algorithm.py ...
55

done

> vars

        x: 55
        function: <function function at 0x0000024B22178AF0>

>

Future

  • Transactional runs, and Undo/Redo - Allow state to be reset to what it was before running a script

  • Change tracking - Keep track of which script run modified which global variable, and when

python-script-rerunner's People

Contributors

tejas-h5 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.