Skip to main content

A tool to run a python function in a module from command line

Project description

Run a python function in a module from command line and shift sys.argv, so function can parse sys.argv properly.

https://travis-ci.org/zhangliyong/pyfuncrun.svg?branch=master Downloads https://coveralls.io/repos/zhangliyong/pyfuncrun/badge.png?branch=master

Install

$ pip install pyfuncrun

Usage

$ pyfuncrun <path.to.func> <func arguments> <arguments for func to parse in sys.argv>

Example

func.py:

import sys


def print_sys_argv():
    print sys.argv


def func_with_args(a, b):
    print ((a + b), sys.argv)


def func_with_kwargs(a, b, c=1):
    print ((a + b + c), sys.argv)

Run:

$ pyfuncrun func.print_sys_argv 1 2
['pyfuncrun', 1, 2]

$ pyfuncrun func.func_with_args 1 2
(3, ['pyfuncrun'])

$ pyfuncrun func.func_with_kwargs 1 2 3 4
(6, ['pyfuncrun', 4])

Project details


Release history Release notifications

This version
History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4.1

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1

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
pyfuncrun-0.1.8.tar.gz (2.1 kB) Copy SHA256 hash SHA256 Source None Aug 6, 2014

Supported by

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