Skip to content

cgarbin/seed-python

Repository files navigation

seed-python

Seed files for Python code

A seed for command-line argument parsing in Python.

Covers:

  • Parsing arguments and options
  • Showing help text
  • Validating presence/absence of mandatory parameters
  • Validating parameter type (e.g. expect a number)
  • Handling optional parameters
  • Handling short (-v) and long (--verbose) version of parameters

It uses argparse because it's available with python. If external depedencies are not a problem, consider using click (while clint and docopt are also good options, click makes a compelling case for itself).

Sources for this code and command-line programs in general:

This program takes two arguments and a few options (argparse gives --help|-h for free):

number1 number1 [--operation add|multiply] (default 'add') [--verbose|-v]

The program adds or multiplies the first two numbers, as specified. Verbose does what is expected: print more information.

A seed for processing files in Python.

Covers:

  • Process more than one file with file globbing
  • Working with pipes (redirect stdin and stdout)
  • Accepting command line options with file names
  • Mutually exclusive command line options with a default option

Does NOT cover:

  • Non-text (binary) files

Sources for this code:

Examples:

file.txt --tolower
file.txt --toupper
file.txt (defaults to '--tolower')
*.txt --tolower  (file globbing)
cat file.txt | thisscript.py (read from stdin)

A seed for data loading, parsing, graphing in Python, using pandas

Covers:

  • Read data from files
  • Manipulate the data
  • Filter data
  • Visualize data in graphs

Sources:

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Seed programs for Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages