Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Let's do flags to it

Liene
August 27, 2015

Let's do flags to it

Command line scripts, flags, APIs, argparse, and a totally legitimate excuse to use 🍃👯💨

Thursday 5-minute talk at Recurse Center, August 2015

Liene

August 27, 2015

Transcript

35 slides
  1. Let’s do flags to it Command line scripts, flags, APIs,

    argparse, and a totally legitimate excuse to use Liene Verzemnieks, 27 Aug 2015, Recurse Center @li3n3
  2. PROBLEMS • Feelings got in the way of my motivation

    • Getting started on something is awful anyway
  3. PROBLEMS • Feelings got in the way of my motivation

    • Getting started on something is awful anyway • THERE IS SO MUCH I DON’T KNOW
  4. PROBLEMS • Feelings got in the way of my motivation

    • Getting started on something is awful anyway • THERE IS SO MUCH I DON’T KNOW • how do you even make something you don’t know how to make
  5. ASSETS • Ceaseless curiosity • Unanswered questions • Tom the

    facilitator (and his friendly persistence)
  6. ASSETS • Ceaseless curiosity • Unanswered questions • Tom the

    facilitator (and his friendly persistence) • An appreciation for the absurd
  7. Down the rabbit hole! • Wanted to do something with

    an API (because I haven’t before)
  8. Down the rabbit hole! • Wanted to do something with

    an API (because I haven’t before) • Wait, how do command-line flags etc. work?
  9. Down the rabbit hole! • Wanted to do something with

    an API (because I haven’t before) • Wait, how do command-line flags etc. work? • Tom said maybe I could do emoji to it
  10. APIs, though • Secret crush on Dark Sky • Turns

    out people with APIs will give you the API key
  11. APIs, though • Secret crush on Dark Sky • Turns

    out people with APIs will give you the API key(s to their heart)
  12. APIs, though • Secret crush on Dark Sky • Turns

    out people with APIs will give you the API key(s to their heart) • apikey = os.environ['DARKSKY_API_KEY']
  13. APIs, though • Secret crush on Dark Sky • Turns

    out people with APIs will give you the API key(s to their heart) • apikey = os.environ[‘DARKSKY_API_KEY'] • Liene + Dark Sky = BFFs 5eva
  14. APIs, though • Secret crush on Dark Sky • Turns

    out people with APIs will give you the API key(s to their heart) • apikey = os.environ[‘DARKSKY_API_KEY'] • Liene + Dark Sky = BFFs 5eva • (also graphs)
  15. Bring me the argparse • How do command-line flags work

    in Python? • Lots of ways (to find more ways than you need, just tweet)
  16. Bring me the argparse • How do command-line flags work

    in Python? • Lots of ways (to find more ways than you need, just tweet) • Argparse is one way
  17. Bring me the argparse • How do command-line flags work

    in Python? • Lots of ways (to find more ways than you need, just tweet) • Argparse is one way, and may give you superpowers
  18. Bring me the argparse • How do command-line flags work

    in Python? • Lots of ways (to find more ways than you need, just tweet) • Argparse is one way, and may give you superpowers • MEGA GIGANTIC DOCS OH GOSH
  19. Bring me the argparse • How do command-line flags work

    in Python? • Lots of ways (to find more ways than you need, just tweet) • Argparse is one way, and may give you superpowers • MEGA GIGANTIC DOCS OH GOSH, but! • Super fun little tutorial
  20. arg, but the good kind # First, we make a

    parser with argparse: parser = argparse.ArgumentParser(description = 'Specify optional preferences.')
  21. arg, but the good kind # First, we make a

    parser with argparse: parser = argparse.ArgumentParser(description = 'Specify optional preferences.') parser.add_argument('--location', '-l', help = 'Specify a particular location') parser.add_argument('--timeframe', '-t', help = 'What timeframe to print out', choices = ['currently', 'minutely', 'hourly', 'daily'])
  22. arg, but the good kind # First, we make a

    parser with argparse: parser = argparse.ArgumentParser(description = 'Specify optional preferences.') parser.add_argument('--location', '-l', help = 'Specify a particular location') parser.add_argument('--timeframe', '-t', help = 'What timeframe to print out', choices = ['currently', 'minutely', 'hourly', 'daily']) # Put all those arguments into something we can use! args = parser.parse_args()

More Decks by Liene

Other Decks in Programming