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


Download files

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

Source Distribution

pyfuncrun-0.1.8.tar.gz (2.1 kB view details)

Uploaded Source

File details

Details for the file pyfuncrun-0.1.8.tar.gz.

File metadata

  • Download URL: pyfuncrun-0.1.8.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyfuncrun-0.1.8.tar.gz
Algorithm Hash digest
SHA256 653c7b40dab379c8f14f6f44e73b2fe47c37c4fb1f875abc49387e5741ac3927
MD5 4962cb50d0d831fdc882de58e5677f22
BLAKE2b-256 a246fb4f9d5c5f44e5379b2b1ad58cce001e583300a51aa23a439da130b1765c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page