Skip to main content

Boilerplate for Python scripting

Project description

Scripting is a boilerplate library for one-off Python scripts when you don’t have an IDE or the like to work with. It was primarily designed for Windows where scripts can be run via double-click, but it (probably) works just as well in a variety of situations.

Here’s an example what a script might look like pre-Scripting:

import traceback


def do_something():
    ...
    return 200

if __name__ == '__main__':  # Run as script
    try:  # Exceptions will close the terminal window
        print(do_something())
    except Exception:
        traceback.print_exc()  # Debug
    finally:
        input()  # Keep the window open

If all you’re writing is a simple script and don’t want to deal with extensive error handling, chances are you’ll end up with something like the above. If you write such scripts often, however, the amount of boilerplate adds up and quickly becomes tedious to maintain.

Post-Scripting:

import scripting


@scripting.main
def do_something():
    ...
    return 200

Scripting takes care of exception handling, output formatting, and maintaining the terminal window for you so that you can focus on getting your script done in the shortest amount of time possible.

Installation

$ pip install python-scripting

Project details


Release history Release notifications

This version
History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
python-scripting-0.1.0.zip (9.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page