Created
July 11, 2017 02:57
-
-
Save godber/be9f26251e915bab030877988b9e91f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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