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


« Return to show page

Transcript for Episode #101:
Nobel Prize awarded to a Python convert

Recorded on Monday, Oct 22, 2018.

00:00 KENNEDY: Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is Episode 101, recorded October 22nd, 2018. I'm Michael Kennedy.

00:11 OKKEN: And I'm Brian Okken.

00:12 KENNEDY: Hey Brian, it's good to be back together.

00:13 OKKEN: Yeah, Python Bytes 101, it's like a introductory course or something.

00:16 KENNEDY: I know, it's beginning Python news for everybody. In fact, we have some very advanced academic stuff that we're going to be covering and some very, very cool frameworks. Before we get to those though, let's say a thank you to DigitalOcean, they're sponsoring Python Bytes for the entire rest of the year, so that's a huge support from them and we really appreciate it, thank you. Check them out at pythonbytes.fm/digitalocean, more about that later. You seem to be picking a fight with asterisks, what's going on here, there's a lot of asterisks in your notes.

00:45 OKKEN: I just asterisks, love asterisks. No.

00:48 KENNEDY: Asterisk to asterisk to asterisk. Yeah, what do you get in Python if you have four asterisks? Come on. The seg fault, I don't know. Anyway, sorry, I'm derailing you, keep going.

00:57 OKKEN: No, I just had, it's one of those things that like they're all over the place, but I thought we covered something like this, but I couldn't find it in our other shows.

01:05 KENNEDY: We covered underscore, we covered underscore.

01:06 OKKEN: Oh, okay.

01:07 KENNEDY: Right, underscore has so many meanings, parentheses have many, many meanings, and asterisks as well. Which I think is, is really interesting, like Python is pretty light on the syntax in the sort of symbol form, but those three things they do a lot.

01:20 OKKEN: They do a lot.

01:22 KENNEDY: And they mean different things, right? So take a stab at this one.

01:26 OKKEN: Yeah, so this is, this is an article from Trey Hunner, that asterisks in Python, what they are and how to use them. And he covers at the beginning, say, yes of course, you can do like 2 * 5, and that's multiplication, and if you do two asterisks together, like 2 ** 5, that's like 2 of the, it's an exponent, it's how you do exponents. But that, that's just like covered in the first few lines and that's a, but what he's really talking about is all the other uses, and I'm starting to use these more, a lot of these different ones more now. But for instance, you can use them if you've got a list, one of the, the first one he starts with that you might use this. If you've got, you've got a list and you want to pass it to a function, but the function doesn't take a list, it takes a whole bunch of arguments, you can put an asterisk in front of the list and it'll get unpacked for you, it's parameter unpacking. I don't think you can unpack not as a parameter, you can, you can unpack to repack, but I don't think you can just pass it to a value or something.

02:30 KENNEDY: Yeah, it's really interesting how you, how you can do that you know, also when you are unpacking tuples, all sorts of interesting stuff there, right?

02:37 OKKEN: Yeah, you can unpack tuples and lists, and then the two asterisks is to unpack keyword arguments, so if you've got a dictionary that holds your keyword arguments and you're going to pass them to a function, you can unpack them first and send them on, on their way.

02:51 KENNEDY: In Python 3.6 you can use them to build dictionaries as well. So you say {**dict1, **dict2} and that creates a dictionary that's basically the union of those two.

03:03 OKKEN: Wow, okay.

03:04 KENNEDY: Yeah, the star, the star, the asterisks, they go crazy, just like the underscore.

03:08 OKKEN: Yeah, so this is, this is actually kind of a hard topic to talk about, but I think it's a good article to review and to just make sure you understand where things are going or just bookmark it so the next time you're confused by somebody else's code you can go look at what they're doing.

03:24 KENNEDY: Yeah, that's a good article by Trey Hunner, I like it.

03:26 OKKEN: Yeah, one of the things that I've, I actually learned from him I think is the, the way to, this is, I think it's a 3.6 thing where it came in, where you can in your parameter list of function of a function when you're defining it you can at some point put an asterisk on one of your items and from there on those items are, they have to be keywords, you can't pass them in positionally, they have to be keyword arguments, so.

03:54 KENNEDY: Yeah, that's really nice, because if you can name the arguments, or you could use positional ones, or you could add the **kwargs, but this means, you know?

04:03 OKKEN: You have to use it.

04:07 KENNEDY: Basically, you can say, you can take a regular argument list and turn it into required only keywords arguments by putting the star as one of the parameters, which is not obvious, but very cool. You want to know what framework is really awesome that uses that as a core feature in it.

04:21 OKKEN: No.

04:21 KENNEDY: Responder. The Responder Web Framework from Kenneth Reitz, which is a brand new web framework. It's a little bit like Flask, but you know, he has requests, and then what responds to requests, well Responder responds to requests, right? So I think if people haven't heard of it, I'm sure some folks have because it's been out for a week or so.

04:41 OKKEN: A week or so.

04:43 KENNEDY: Yeah, so what that means is it already has like 1,300, it's up 1,400 GitHub stars 'cause it's Kenneth's work and it's been out for like a week and a half. Which is pretty cool. So very popular and it's sort of the web side, the server site equivalent of his requests API, and he's trying to make something a little like Flask, but more friendly, easier to work with, easier to test, things like that. So let me run through some of the things that it does as its core features. It has a pleasant API, which is cool, with a single import statement. So you know, you would expect Kenneth have put together a sweet API. It has class based views without inheritance. It's naturally first an asynchronous web frameworks, so it supports async and await and it comes with ASGI web server, so you can just run it and it will start processing asynchronous requests, whereas you know, Flask and those things don't have that yet so that's pretty, that's a pretty big thing. Because of that it's going to be easy to support web sockets, you can take an existing WSGI app like Flask or Pyramid and mount it as a sub-route. So what that means is if I have some, let's say if I blog or you know, I'd ordering system, and then I went to like plug that in as a sub-part of this, I don't have to rewrite that, I can just like mount that as a URL and anything, and say, under /store goes to that implementation, and the rest is this new app. So that's a pretty cool feature, right?

06:11 OKKEN: Yeah, it also makes it so you can split up the responsibility of maintenance and stuff.

06:14 KENNEDY: Yeah, it's fair, yeah, yeah, you could break it up like one team manages this part, another team manages that, but on the server side it looks like all one thing. I suspect you could probably pull it off with like Nginx and stuff, but this way you don't have to you know, do it in infrastructure, you can, you can do it in your Python code. It has background task support, GraphQL, OpenAPI, schema generation which is cool, SPA, single page app support. Let's see, it's built on top of uvicorn which is one of the faster asyncio loops like uvloop and so on, and yeah, it's even got a nice ASGI support like I said, for async stuff. So, I don't know if the world needs more web frameworks, it feels like we have a lot of these, but I also feel like this is going to be a massive success just the way you look at it.

07:03 OKKEN: Yeah, and a lot of our building on top of what other people have learned and, and so it's okay to keep rolling out new ones.

07:10 KENNEDY: Yeah, so one of the things that you know, maybe you'd like this a little better, but one of the things with Flask is it has a sort of ambient request that doesn't get passed to the method, it's just you know, there like a global variable, but it's thread local or something like this. Which means it's a little harder to test, right, 'cause how do you mock out that thing properly all the time? And this one takes the request and the response so you can modify the response really easily, and then it says *, comma, and then all of the values that go into the route, like /{var_name}. Those just become keyword arguments using exactly that thing you were talking about.

07:45 OKKEN: Oh, nice, okay.

07:45 KENNEDY: That's cool, right, yeah. Anyways, so... If, if people want to see what Kenneth is up to with his web frame work, it seems like it's getting some traction, and that's, that's pretty cool.

07:55 OKKEN: And even though it's just started they've already, he's got a built-in test client for it, so that's cool. I have to check that out.

08:03 KENNEDY: Yeah, absolutely. All right, what's your next you got?

08:07 OKKEN: Mm, let me see, it's down the line, just a second.

08:08 KENNEDY: And it's hiding.

08:08 OKKEN: It's hiding, yeah. So I ran across, I actually saw somebody reference this website because the website is pythonprogramming.in, I'm not sure what the in is, but anyway, pythonprogramming.in, and it was, they were referenced looking at the referencing the Pandas examples, but it's, it's kind of a lot more. It looks like kind of a tutorial on Python and then, so it has just short descriptions, and actually short or no descriptions, so just really short with some examples.

08:40 KENNEDY: Titles basically.

08:42 OKKEN: Yeah, titles with, well a little paragraph of what's going on, and then a little code snippet, and then the example, the output of the examples, so it's teaching just through code and examles for the most part. But it goes through like, starts out with Python basics, and then datetimes and strings and dictionaries, but then quickly jumps into Pandas, matploblib and even TensorFlow.

09:04 KENNEDY: There are many, many topics on say, Pandas for example, there's probably four to five pages, and each one of those is like an article and a bunch of sample code and stuff, right? Or at least some sample code.

09:17 OKKEN: Yeah, and also the way they're doing a lot of these examples' titles are kind of not how it's implemented, but what you want to get done, so that's kind of neat.

09:28 KENNEDY: Now that's a good point. Yeah, that's nice because you maybe don't know when you're new.

09:31 OKKEN: Yeah, how do I Google this?

09:33 KENNEDY: I'm going to do this thing, I just know I have this problem, how the heck do I solve this? Yeah, that is pretty cool. So it looks like it's probably a really good resource if I'm somewhat new to Python, maybe entirely new, and I want to do data science, 'cause it goes through all the basics of the language and then Pandas, matplotlib and Tenserflow.

09:51 OKKEN: Yeah, it's like a total deep end crash course, but pretty nice looking and it's cool.

09:58 KENNEDY: Awesome, well it looks like a great resource, especially for people learning data science. I know that it's one of the hot areas and a lot of people are getting jobs there and so that's, that's awesome.

10:06 OKKEN: Well what have you got for us?

10:08 KENNEDY: Well before I tell you about the next thing which I am quite excited about. Maybe if I were super lucky I could make this into a full episode somehow on Talk Python, we will see, but first, I want to tell you about Kubernetes over at DigitalOcean. So DigitalOcean has now announced their Kubernetes cluster and support, so for as little as five dollars you can spin up a droplet there, terminology for a virtual machine, and it comes pre-configured to be a Kubernetes cluster. So if you want to work with Docker and group this stuff with Kubernetes and just get rolling with things like zero down time, upgrades, downgrades, all that kind of stuff, scaling, Kubernetes is really great to do that and you can do it cheap and easy on DigitalOcean. So check them out pythonbytes.fm/digitalocean and get started, and if you are a new user there you can get $100 credit to play with Kubernetes and other things as well.

10:59 OKKEN: Nice.

11:01 KENNEDY: Yeah, they also have GPU based systems and high compute stuff if you want to do data science over there, so that's, that's pretty awesome. The next thing that I have has to do with Sweden actually.

11:12 OKKEN: With Sweden?

11:12 KENNEDY: Yeah, with Sweden. Sweden is pretty awesome.

11:14 OKKEN: Sweden.

11:16 KENNEDY: I haven't got to spend much time in Sweden, but I definitely like the place, and the news is there's these two American economists who have won the Nobel Prize in economics, and that's Sweden.

11:28 OKKEN: Oh, okay.

11:29 KENNEDY: Right, 'cause that's who hands out the Nobel Prize. And interesting, okay, so they're economists, they won the Nobel Prize, they, it was Nordhaus and Romer, they basically just signed some ways to model and analyze how to sustain economic growth in a global economy like it is, and also what destroys it. So, it's basically like a theory of the welfare of the world's population and economy, which is pretty cool. But why am I talking about it? Because one of the guys, I think Romer, I'm pretty sure it's Romer, yeah, Romer, is become a Python and Jupyter convert and doing his work and his publishing for his Nobel Prize with Jupyter and Python.

12:09 OKKEN: Oh, that's so cool.

12:12 KENNEDY: Isn't that sweet? So first of all, the guy's 62 years old and he has just switched to Python which is awesome.

12:19 OKKEN: Yeah, that's great.

12:20 KENNEDY: So he said he believes that research should be transparent and he really thinks it's important that it's open and reproducible, and like most academics he worked in some other closed ultra-expensive thing, so he worked in Mathematica, right, Mathematica's willing to pay things, and he said, try to share his work, right, this Nobel Prize winning work, he tried to share it, and he said he couldn't do it. Wolfram Research, who makes Mathematica, basically made it impossible to share his research without the people receiving it also having Mathematica, the paid version.

12:52 OKKEN: Yeah, they, that's lame.

12:55 KENNEDY: Yeah, it's totally lame. So he had some pretty interesting comments. He says he believes that open source notebooks are the way forward for shared research and he believes they support integrity while proprietary software encourages secrecy. And he went on to say, "The more I learn about proprietary software the more I worry that objective truth might perish from the earth." he wrote, so. How's that for a statement? That's pretty wild, so anyway, there is a short article, you can check it out, it actually links to a bunch of his blog posts and his writings from Dr. Romer that's cool. I actually also interviewed the folks that won the Nobel Prize in physics at CERN, not Higgs, but the people on the team that did the research, like the leaders of some of the teams there on Talk Python way, way back, and I'm going to link to that, I think it was Episode 29 about CERN, that was pretty awesome.

13:45 OKKEN: Yeah. That was, that was a great episode.

13:48 KENNEDY: Yeah, thanks, it's one of my favorites.

13:50 OKKEN: And I'd like to, I'd like to actually hear more about people, it's neat seeing this in economics, I'd like to hear more about people using Python in economics.

13:58 KENNEDY: Yeah, yeah, I mean I might send him a message and say hey, if you've got the time, I'm sure you're busy, but you know? Come on the show, that'll be awesome. All right, what's your next one?

14:05 OKKEN: Speaking of science, so that last link we had, we had some basics of TensorFlow, but if you really want to jump into it we've got, there's a GitHub Repo that has simple and ready to use tutorials for TensorFlow in a whole bunch of different, in the repo, so you can, you can kind of get started and get kind of deep into it with some open sources examples so that's what I have to share really.

14:31 KENNEDY: Nice, you know, I feel like I really just need to take some time and learn some of the AI machine learning stuff. It's really interesting and it seems super approachable, it's just I don't know, I don't know how you feel Brian, but for me, it's like I need to have a problem to solve to really learn something.

14:48 OKKEN: Yeah, I definitely agree, I'm trying to figure out how to and since I work with communication systems and measurement of those, and I think that there's some room there that I could possibly use some machine learning or something in that realm.

15:02 KENNEDY: Yeah, you probably can. You know, the folks over at Netflix they use machine learning to analyze and then watch all of their servers 'cause they have too many for a human to understand, and basically the system knows when it's broken before they do. Yeah, so that's pretty awesome, so maybe it works it works with Radius as well, the servers.

15:20 OKKEN: Yeah, maybe, that'd be cool.

15:20 KENNEDY: Possibly. So the final thing is something that people might actually be super interested in being part of and it's going to be available at the time of this recording for this 31 more days, probably by the time it ships maybe 28 days, who knows, something like this, is this thing called Makerphone. Have you heard of this?

15:42 OKKEN: I have, it's pretty darn cool.

15:44 KENNEDY: So Makerphone is from this guy named Albert in Croatia and he had made something previously and what was it called, I can't remember, it was like a little hand held, almost like a Nintendo NES that you could program with super basic graphics, it was pretty interesting. The problem was that you programmed in C, what this is, Makerphone is a smartphone with a screen that you program in Python.

16:12 OKKEN: Yes, that's super cool, smartphone is a little bit of a stretch.

16:15 KENNEDY: Smartphone in quotes, it's not super smart, but it does have a screen, I don't think it was a touch screen but it has a screen and the little keypad and also I like this one because you can basically choose your level of commitment to the DIY do it yourself aspect. You can back the Kickstarter at a level that will get you just the true experience, here's the boards, the wires, and the soldering, go to town on these instructions, or offer like a little tiny bit more you can get it assembled, so you can just write the software.

16:48 OKKEN: Yeah, that's pretty cool.

16:50 KENNEDY: Yeah, so I actually back this at the software level 'cause I'm busy, I can't do soldering stuff, I would like to but I'm afraid I'll just not do it so I'd rather just try the software side.

16:59 OKKEN: That's pretty cool that you backed it, I can't wait to see it, I was thinking about it. One of the neat things about the we watched the video, some of the belief like it's a small company around this, is that it isn't to try to get you a cheap phone, it's to help teach people so it's trying to get people excited about learning how to solder parts together and learning how to program stuff, getting all this working and with like a webpage that will walk everybody through whatever they need to do with it. And that sort of thing is neat because it's missing out of a lot of places, I mean we don't have Radio Shacks anymore so people have to do these maker things to figure out some of this stuff, so.

17:39 KENNEDY: Yeah, it looks really, really fun and I'm excited to do it, you can program it in Scratch or Python, it's also Arduino based so you probably can program it in C++ as well. I'm excited, the reason I got it is my daughter is really into making websites with Python, like simple, super super simple ones with say Anvil. And where she can kind of drag and drop some stuff together and put like a silly dropdown in a picture or something, you know, something really simple, but I feel like we could sit down and make some little simple games like you know, a little pong based game or something on this phone and I bet she will love it, we'll see. That's the goal anyway.

18:17 OKKEN: Yeah, and even if you already have it prebuilt I'm sure you could take it apart and look how, what's inside and everything, so.

18:23 KENNEDY: Yeah, absolutely. So this, and there it'll be for sale afterwards, they've made that NES like thing previously which I talked about that's still for sale and not too expensive. So one of the things about Kickstarter is will the thing actually become a reality, right? They put this one that was the goal has to be $15,000 in order to do it.

18:44 OKKEN: Yeah, they hit that right away.

18:46 KENNEDY: Yeah, I don't know how many days it's been out for but it's at $186,000 pledged and 31 days to go. So I bet this thing hits half a million. Especially now that we covered it on the show, I mean they didn't pay us anything, I just think this is super interesting and the Python's angle awesome, but I bet it hits half a million.

19:03 OKKEN: It's pretty neat.

19:05 KENNEDY: What's crazy Brian is this guy did the first project when he was, as a Kickstarter when he was 18, I didn't bother to look actually what that brought in, now he's much more mature, he's been working at this for a while, he's now 20, isn't this cool for a guy who's 20 to be doing this?

19:19 OKKEN: It is and that's one of the thing, neat things about this project also is that it's not his first project, so now that you've done it you got to actually build it. He's already done that, so.

19:29 KENNEDY: Yeah, there's a good chance it won't be Vaperware 'cause he's selling the previous Kickstarter thing. Yep, pretty awesome. Well I'm excited to get mine and build pong with my daughter

19:37 OKKEN: All right, cool.

19:40 KENNEDY: I did want to throw out one more thing really quick. So there's been all this talk about Python 2 versus Python 3 Legacy Python, Modern Python, what's going to happen. Well you know, PHP has something not terribly different to go in on.

19:53 OKKEN: Really?

19:54 KENNEDY: There is this article, I'm just going to read you the title, I think it's overgeneralizing, anyway, the title is Around 62% of All Internet Sites will run an unsupported PHP version in 10 weeks. I don't know if it's actually 62% of all sites or all PHP based sites, but Wordpress is so prevalent on the internet that you know, that's probably not a super big difference, I don't know, but it's pretty interesting to see the conversations and some people are saying I think it's sort of a shadow of what's to come in 2020 for Python 2 when it goes out of date as well. So it's just an interesting article, I'll throw it out there basically the summary is the highly popular PHP 5 branch will stop receiving security updates at the end of the year just like Python 2 will next year.

20:40 OKKEN: Yeah, okay.

20:40 KENNEDY: Yeah, anyway, it parallels.

20:43 OKKEN: Well that's a show man.

20:44 KENNEDY: It's definitely a show and we are, we are into triple digits properly now with 101. So what's the next one, 201? I guess, was this a prerequisite for the next one? You know, what's the? Nah, it'll be fun. It's been great to do it and we're going to keep cranking out, it'll be 102 I suppose.

21:01 OKKEN: Probably, yeah, that makes sense.

21:03 KENNEDY: It does.

21:03 OKKEN: All right.

21:04 KENNEDY: With you know, counting and all that.

21:07 OKKEN: Talk to you next week.

21:08 KENNEDY: See ya.

21:08 OKKEN: Bye.

21:09 KENNEDY: Thank you for listening to Python Bytes. Follow the show on Twitter via @PythonBytes, that's PythonBytes, as in B-Y-T-E-S, and get the full show notes at pythonbytes.fm. If you have a news item you want featured just visit pythonbytes.fm and send it our way, we're always on the lookout for sharing something cool. On behalf of myself and Brian Okken this is Michael Kennedy, thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page