Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #27: The PyCon 2017 recap and functional Python

Return to episode page view on github
Recorded on Tuesday, May 23, 2017.

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:06 This is one of your hosts, Michael Kennedy.

00:09 And this is Brian Okken.

00:11 And we're here with our first post-PyCon episode.

00:15 So, Brian, let's just jump straight into it.

00:18 How was PyCon for you?

00:19 Yeah, I wanted to bring up that right away because it was incredible.

00:22 It's the first one I've been to.

00:24 And I got to say, it was even more than I expected.

00:29 Hard to put in word.

00:29 We hung out.

00:30 We had a booth there.

00:32 Thanks to everybody that showed up to say hi.

00:35 Apologies to anybody that stopped by and we weren't around at the time.

00:39 But, Michael, you were pretty good about hanging out and talking with everybody.

00:42 Yeah, I went deep into the hallway track.

00:44 Yeah.

00:45 Which meant I mostly ended up spending time at the booth having conversation with people or at other people's booth talking to them or something to that effect.

00:55 That's the real value of PyCon to me.

00:57 Like, I think the talks are amazing.

00:59 And I really enjoy the keynotes and things like that.

01:03 But the open spaces and these, like, impromptu meetings, that's where it's at for me with PyCon.

01:10 Yeah, actually, the open spaces, that's something I didn't really do much.

01:13 And I think that I'll have to make sure to do that more next time.

01:17 They put up those.

01:19 For anybody that hasn't gone, they put up these boards with just, like, a whole bunch of empty rooms.

01:24 And you can just sign up for a time slot.

01:26 And if you get it, you have it.

01:28 They start out fresh each morning.

01:31 So, people just hang out and do things.

01:34 And it's not just all testing related.

01:35 Or not testing related.

01:37 Python related.

01:38 Sometimes they do things like tie knots and stuff like that.

01:43 Yeah, one thing that I went to was how to start a business.

01:46 One that I went to was how to market yourself as a developer.

01:50 And then I actually ran two.

01:52 One was, like, a Python podcaster meetup.

01:55 That was really cool.

01:55 A bunch of people came.

01:56 Thanks to everyone who came.

01:58 And then one on out-of-the-box ideas for improving the diversity of funding for PyPI.

02:05 So, that's something that will be coming out later.

02:07 That requires some write-up.

02:08 Oh, that's cool.

02:09 Yeah.

02:09 For my benefit, as well as the people listening, I'm going to put a link to the YouTube channel with all of the talks.

02:17 Unfortunately, all these, like, open spaces and stuff aren't recorded.

02:22 But one of the things that also I wanted to bring up was that I was surprised how much I enjoyed the lightning talks.

02:29 I think it's neat to have a full range of people that are really great at speaking and people that they're new to it as well.

02:38 Yeah, it's pretty.

02:39 If you want to try your hand at public speaking and you're new, like, five minutes is not too tough.

02:44 Although it's a big audience, it's only five minutes.

02:46 Yeah.

02:47 Okay.

02:48 And, yeah, lastly, I wanted to say it's amazing.

02:52 How many people know Michael?

02:53 Man.

02:56 I also find this amazing.

02:57 It's, like, entirely humbling and, you know, it was amazing.

03:00 Yeah.

03:00 Okay.

03:01 Well, let's move on.

03:03 Awesome.

03:03 Okay.

03:04 So, keeping in the current latest state-of-the-art, like we talked about with many, many things at PyCon, we recently heard that AWS Lambda, which has nothing to do with Python Lambdas, it's just the serverless computing offering from AWS, has started supporting Python 3.6.

03:22 And so, someone else who was there at the conference was Matt McKay from Fullstack Python.

03:27 And he put together this little quick tutorial on just how can you quickly set up a AWS Lambda Python 3.6 function and do some interesting things like read from the environment variables and things like that to create this little app.

03:43 Nice.

03:43 Yeah.

03:43 So, basically, if you can write a function, like a single function, then you can pretty much write and deploy these AWS Lambda functions, which, if you have something kind of like a micro service, micro architecture type thing, then, you know, maybe it makes a lot of sense to do it as these little AWS Lambdas.

04:04 I'm actually going to have a guy tomorrow, a guy named Ryan, come and talk about serverless computing in general on Talk Python.

04:11 But here's a little precursor if people want to check this out.

04:15 Oh, that's cool.

04:15 I'll be looking forward to listening to that.

04:18 I was just curious on the Lambdas.

04:21 Do you know if the functions you put in there have to have names?

04:25 They have names, but you basically map them to endpoints that you can set up.

04:28 And there's all sorts of events.

04:30 Like, they maybe are not even public in terms of HTTP.

04:34 Like, they might not be web service endpoints.

04:36 They could be.

04:37 It's basically event-driven.

04:39 So, for example, you can say, I would like this function here, whatever you name it.

04:44 It's kind of irrelevant, but you have to pick the name, right?

04:47 I would like this function here to execute when somebody uploads a file to this subfolder, this bucket in S3.

04:55 Okay.

04:55 Right?

04:55 So, maybe you're going to do, like, let's say we have a video delivery service for, like, training or something.

05:02 Well, if you upload a new video, you might want to create an adaptive stream, like a low bandwidth, a high bandwidth version, different formats, like MP4 versus WebM or something like that.

05:15 Like, you could detect when a file is dropped there and automatically, by virtue of effectively just uploading to S3, have this code manage and juggle all that in the background, and you don't ever have to do anything.

05:26 So, you can set up these cool event-triggered things, but it could just be as simple as, like, here's an HTTP endpoint.

05:32 Okay.

05:33 I'm going to try that out.

05:34 Yeah, it's pretty cool.

05:35 Definitely.

05:35 One of the things I talked about at the conference was PyPI and the Python Packaging Authority and so on.

05:41 And that was around funding.

05:44 But, you know, one of the reasons they have such a challenge with their infrastructure is because they have so many packages, right?

05:51 Yeah.

05:51 Yes.

05:52 And so, you should put some more out there, everybody.

05:54 Yes.

05:55 Everybody, let's make more.

05:56 Let's do more of that.

05:57 There's a pretty good JetBrains article called How to Publish Your Package on PyPI.

06:02 I think it does a really good job on talking about what all you have to put into your package.

06:09 The structuring is pretty good, although I'd like to see them include the source directory in their article.

06:17 But one of the things I liked was just a discussion of all the contents of the setup.py file, all the stuff that you've got to put in there, your license, your email.

06:28 And I guess it's all pretty obvious.

06:30 But when you just see it all in an example setup, it can be a little overwhelming.

06:36 But it's really, there's the minimal amount of stuff you put in there.

06:39 It's just not that complicated to put in there.

06:43 I also liked that they, I hadn't seen a decent example recently of what you ought to put in your PYPIRC file.

06:52 So, I guess it's like a, yeah, config file for, so that you can talk to PyPI easily.

06:59 Right.

06:59 Like, I think you could put like your account information so you don't have to like log in every time and stuff like that, right?

07:04 Yeah.

07:05 And then they talked about using Twine to push both to the test, the test repository, I guess, and then the actual one.

07:14 That's something that people ought to do also.

07:16 If you just want to try this out, but you don't have a package that you're ready to actually put out there to the world yet,

07:23 you can use their test server and push things up and try it out.

07:27 Yeah, definitely make use of the test server.

07:28 And what surprised me is actually how easy it is to put something on PyPI.

07:33 I found most of the difficulties that I ran into when I did this were actually around packaging itself, just purely packaging.

07:40 And once you kind of had that solved, it was like, it wasn't too bad.

07:43 Yeah, and I actually encourage people to just, yeah, come up with something and try it out.

07:48 I have to drink my own Kool-Aid with this one.

07:51 I still haven't put anything out there, so I got to put a couple of things up there.

07:55 Yeah, maybe after you're done writing your book, huh?

07:57 Yeah, actually, there's a lot of, quite a few pytest plugins that I'd like to write and put up there.

08:03 Oh yeah, that'd be a good set.

08:04 That'd be good.

08:04 Yeah, that'd be awesome.

08:05 Speaking of Pythons, Pythons live the same place where there are coconuts, right?

08:10 No, that's...

08:12 So, the next thing that we're going to talk about is called coconut.

08:16 And there is a tie-in to Python.

08:18 But you've got to go back to the origins.

08:21 Back to Monty Python.

08:23 Oh, right.

08:24 Yeah, okay.

08:24 Right, you know those knights that run around and they've got like those coconuts, they click together.

08:29 Yeah.

08:29 Because they don't actually have horses, but it sounds like the galloping, basically.

08:33 We should have had some for the show.

08:35 We should have brought some to PyCon and just run around with them.

08:38 Next year, we know what to bring to Ohio.

08:42 Okay, so the next thing I want to talk about is a Pythonic functional programming language.

08:49 Now, functional programming, you know, some people are really into it.

08:53 Some people are, I don't know, kind of stay away from it.

08:56 To me, it's one of those languages where it's kind of like a good puzzle more than, I don't know, like building blocks.

09:03 But it's more like this thing you have to sort of, you write a little bit of code and then you think about it for a long time, deeply.

09:10 And then you write two more, you know, characters and you're done or something like this, right?

09:16 So it's very concise and it's very interesting to write, you know, basically functional programming.

09:21 And there's many options that have been for a long time.

09:23 Scheme, Haskell, whatever, right?

09:25 F-sharp, Erlang, you name it.

09:28 But as Python programmers, we have all of our awesome PyPI packages, just as we talked about.

09:35 And we may have some more after the session, right?

09:37 So we have all of those and then we may be of existing Python code.

09:41 So Coconut is a functional programming language that is deeply functional and unique, but is a superset of Python, Python 3 specifically.

09:52 So what that means is you can take a given existing Python 3 code and go and rewrite one function or one algorithm functionally rather than imperatively.

10:04 And you can use all the PyPI packages because it's just Python.

10:08 Okay.

10:09 So you can gradually add functional programming to an existing application or something.

10:14 Right.

10:14 And you don't have to start over.

10:15 Like you have to learn the functional programming concepts where they apply, but you don't have to use them all the time.

10:20 You can just use them where they make sense.

10:22 So there's all kinds of unique things for Coconut.

10:25 There's pattern matching, which I'll tell you what that is in a minute because that's wild.

10:29 There's basically algebraic data types, which are immutable data types.

10:35 Think anytime you see a class, replace the word class with data and that becomes immutable.

10:39 But there's some other cool stuff that happens.

10:41 Really interesting parallelization operations.

10:45 Because once you have immutable data types, many of the problems that you solve by paralyzing them, these algorithms become what's called embarrassingly parallel.

10:56 Right.

10:57 Embarrassingly parallelizable.

10:58 Right.

10:58 Like if there's no real interaction because everything's read only, well, just let it roll.

11:03 Right.

11:03 Just fork it out and just give the pieces to little sub processes or something.

11:07 So there's a lot of cool stuff.

11:09 But just to give you a sense, I'll tell you about the pattern matching.

11:11 Suppose I want to write a recursive function or let's just say a function that implements, like say factorial.

11:19 That's their example they have.

11:20 You would have a function.

11:22 It would take a number.

11:23 It would have a test.

11:24 It would say if this number is zero, then return one.

11:28 Otherwise, do some multiplication stuff with the current number plus times the factorial of n minus one.

11:35 Something like that.

11:36 Right.

11:36 And you would do this kind of recursion thing.

11:37 So you have these if statements for different situations in your function.

11:42 In coconut, you can define one function for the degenerative case and another function for different situations.

11:50 So, for example, like your parameters can say, I would like to take an n, but only if the n is an integer and it's greater than zero.

12:00 Oh, wacky.

12:01 It's kind of like a method overloading in, say, C++, C#, Java, where it might match by type or type plus number of parameters.

12:09 It does that, but by if statement.

12:12 It's crazy.

12:13 Okay.

12:13 It's pretty mind-bending.

12:14 Anyway, people, check it out.

12:16 There's a cool tutorial.

12:17 It's just pip install coconut, so easy to get started with.

12:20 It's definitely worth looking at because, you know, it'll make you think a little differently, which is always good.

12:25 Well, thanks.

12:25 I guess I'm just going to go back to packaging again.

12:28 But one of the things that I have had trouble with is understanding all the open source licenses.

12:35 And I guess I got into open source a little bit when everybody was afraid of the GPL, especially in the corporate circles.

12:43 And now, you know, I just knew that MIT was, like, not as freaky, I guess.

12:51 MIT is, like, super simple and permissive if you want to use it, but it's hard to decide.

12:57 For these more permissive licenses, for me, it's hard to decide, like, well, what if I want some restrictions?

13:03 Right.

13:03 Right?

13:03 It's like, what can I offer this useful to people, but it has, like, the kind of protections I would like to have in this code, right?

13:10 Plus, if you start reading it into it, there's a bunch of legalese that, like, I just glaze over.

13:15 My eyes glaze over.

13:17 So I ran across a site called choosealicense.com, and it's pretty darn cool.

13:24 It talks about the MIT and Apache and GPL, but it also has, like, a cool list of all of the whole bunch of different licenses

13:32 and has some color-coded bullets for what you're getting with those and what you're giving up and what rights you keep and all that.

13:41 And I like it.

13:42 It's good.

13:43 Yeah, very nice.

13:44 Very nice.

13:44 We even have the unlicensed covered there.

13:47 Which is pretty cool.

13:48 And then also a comment about you don't have to, you don't actually have to pick a license if you don't want to.

13:53 There's nobody forcing you to.

13:54 Yeah, yeah, in which case you pretty much just retain the copyright.

13:57 There's somewhat of a problem with that on GitHub, I believe, in that there's a number of what are meant to be open source projects on GitHub

14:06 that just whoever created the repo didn't do the little dropdown and say, yes, pick a license and choose one.

14:12 And so there's the stuff that looks like public open source because it's publicly accessible and it's on GitHub and you can clone it and do stuff.

14:20 But there's technically no license, so it's not really open source, which is kind of interesting.

14:24 Yeah, and I guess one of the reasons why I picked up on this is because I'm trying to teach people to use simple setup files so that you can make a package pip installable even locally.

14:37 And one of the requirements is you have to fill something in for license.

14:41 So you may as well just kind of think about it a little bit ahead of time so that you can throw it in there.

14:47 Anyway.

14:48 Yep, absolutely.

14:48 It's a good idea.

14:49 All right.

14:50 Let's round it out with something free for people.

14:53 A free book.

14:54 So there's a book called Python for Scientists and Engineers.

14:57 And I think this was not free before, but now just became free.

15:02 So this is a book if you're getting into basically using Python for science or machine learning or natural language processing, all these different things.

15:12 There's a bunch of examples of using it there.

15:15 All right.

15:15 So just to give you a sense, there's like some introductory stuff.

15:18 And then they've got image and video processing in Python, data analysis with pandas, audio and digital signal processing.

15:24 Of course, you've got to control your Raspberry Pi with Python because who wouldn't want that?

15:30 A couple of things on machine learning like building an Amazon-like recommendation engine.

15:35 And then a bunch of stuff on natural language processing and sentiment analysis and looking for spam and, you know, basically text processing type things.

15:44 So if learning about those things and dabbling in those things sounds interesting, here's a book with a bunch of applied chapters.

15:51 Nice.

15:51 Lots of cool stuff in there.

15:52 There's all these cool things that I would love to know and would love to learn and have no applicable use for in my world.

15:59 You know what I mean?

16:01 Like I would love to build like a machine learning sort of something, but I have nothing to turn machine learning loose on right now.

16:08 Yeah.

16:08 And one of the things that I noticed in here is the audio and digital signal processing section.

16:14 I think that's pretty cool because it's been on pretty hard to get into DSP stuff before Python and some of the engineering tools that came about with Python made it a lot easier.

16:27 So that's pretty neat.

16:28 Yeah, absolutely.

16:28 Yeah.

16:29 Yeah.

16:29 Very cool.

16:30 So that's our news for this week.

16:31 I don't know about your podcast, but mine is definitely going to be a buzz with lots of stuff that we learned at PyCon.

16:38 So I want to loop it back to the very first thing that you covered.

16:41 Be sure to go check out those videos.

16:43 I don't know how many there are, but it's like a hundred presentations.

16:47 It's crazy.

16:48 And there's so many good ones.

16:49 Actually, I'm not watching them while driving, but I'm listening to them while driving and then just knowing to get back to the slides later if I want to see that.

16:58 Yeah.

16:59 And a lot of those talks, I think you can get like the 80% just in audio and it's probably good enough because you might not watch it all, but you're stuck in traffic.

17:07 So why not?

17:07 Right?

17:08 Yeah, definitely.

17:09 Right on.

17:09 So how's the book?

17:11 I saw a great giant like floor to head height banner of the book, but what's that mean for the rest of us?

17:21 It was a nice timing.

17:22 It was hard to get it out, but we got the beta out available.

17:26 So it's not available in hardback yet, but Python testing with pytest is available within a beta.

17:33 So the first five chapters are ready and the first five chapters cover like just about everything you need to know.

17:40 The only thing that's left to wrap up in the last couple of chapters is the configuration files, like the any file and stuff like that.

17:48 And then the last chapter is going to be using pytest with other tools like with Selenium and with continuous integration.

17:55 These are definitely meaty, nice things, but they are not things that are necessary to get learning.

18:01 And I've already had one of the comments from Twitter is somebody bought it and said, wow, this is like the best thing to learn pytest.

18:10 So that was a good.

18:11 That's got to make you feel good after like months and months of months of working in isolation.

18:17 Yeah, yeah, definitely.

18:19 And also just like it's been an incredible experience working with an editor too.

18:23 It's been good.

18:24 Yeah, yeah, I'm sure it has.

18:26 That's awesome.

18:26 All right.

18:27 Well, we have a link at the bottom of the show notes.

18:29 And so people want to check it out, they can totally do that, right?

18:31 Yeah.

18:31 All right.

18:32 Well, that's it for this week.

18:33 Brian, as always, thank you.

18:35 It was great to hang out with you at PyCon.

18:37 And once again, thanks to everyone who stopped by.

18:39 We met so many people.

18:40 It was really amazing.

18:41 Right.

18:41 Incredible.

18:41 Thanks.

18:43 Thank you for listening to Python Bytes.

18:45 Follow the show on Twitter via at Python Bytes.

18:48 That's Python Bytes as in B-Y-T-E-S.

18:51 And get the full show notes at pythonbytes.fm.

18:54 If you have a news item you want featured, just visit pythonbytes.fm and send it our way.

18:58 We're always on the lookout for sharing something cool.

19:01 On behalf of myself and Brian Okken, this is Michael Kennedy.

19:05 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page