Skip to content

Instantly share code, notes, and snippets.

@godber
Created July 11, 2017 02:57
Show Gist options
  • Save godber/be9f26251e915bab030877988b9e91f3 to your computer and use it in GitHub Desktop.
Save godber/be9f26251e915bab030877988b9e91f3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Create a parameter YAML file: parms1.yml that contains
# m: 1
# b: 5
import yaml
import click
def line(x, m=None, b=None):
return (m * x + b)
@click.command()
@click.argument('filename')
@click.argument('x')
def main(filename, x):
with open(filename, 'r') as stream:
try:
parms = yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)
print(line(int(x), **parms))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment