Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

PROBLEMS • Feelings got in the way of my motivation

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

ASSETS • Ceaseless curiosity

Slide 9

Slide 9 text

ASSETS • Ceaseless curiosity • Unanswered questions

Slide 10

Slide 10 text

ASSETS • Ceaseless curiosity • Unanswered questions • Tom the facilitator

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

ASSETS • Ceaseless curiosity • Unanswered questions • Tom the facilitator (and his friendly persistence) • An appreciation for the absurd

Slide 13

Slide 13 text

Down the rabbit hole! • Wanted to do something with an API

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

APIs, though • Secret crush on Dark Sky

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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']

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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)

Slide 23

Slide 23 text

Bring me the argparse • How do command-line flags work in Python?

Slide 24

Slide 24 text

Bring me the argparse • How do command-line flags work in Python? • Lots of ways

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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'])

Slide 32

Slide 32 text

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()

Slide 33

Slide 33 text

~*~ definitely ~*~ ~*~ not the worst ~*~*

Slide 34

Slide 34 text

LIVE COMMAND LINE ⏰

Slide 35

Slide 35 text

YES! https://github.com/li3n3/weather_balloon