Python Bytes - #101 Nobel Prize awarded to a Python convert

Episode Date: October 24, 2018

Topics covered in this episode: Asterisks in Python: what they are and how to use them responder web framework * Python Example resource:* pythonprogramming.in More in depth TensorFlow MAKERphone -... an educational DIY mobile phone Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/101

Transcript
Discussion (0)
Starting point is 00:00:00 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. And I'm Brian Notkin. Hey Brian, it's good to be back together. Yeah, Python Bytes 101, it's like an introductory course or something. 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 thank you to DigitalOcean.
Starting point is 00:00:32 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 slash 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.
Starting point is 00:00:46 I just asterisks, love asterisks. No. Asterisks, asterisks with asterisks. What's going on here? There's a lot of asterisks in your notes. I just asterisks, love asterisks. No. Asterisks, asterisks, asterisks. Yeah. What do you get in Python if you have four asterisks? Come on. Segfault? I don't know.
Starting point is 00:00:54 Anyway, sorry. I'm derailing you. Keep going. 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 show. We covered underscore. We covered underscore. We covered underscore. Right. Underscore has so many meanings.
Starting point is 00:01:09 Parentheses have many, many meanings. And asterisks as well, which I think is really interesting. Like Python's pretty light on the syntax in the sort of symbol form. But those three things, they do a lot. They do a lot. They mean different things, right? So take us through this one. Yeah.
Starting point is 00:01:24 So this is an article from Trey Hunter. Asterisks in Python. they do a lot they do a lot they mean different things right so take a serious one yeah so this is um this is an article from trey hunter asterix and python uh what they are and how to use them and uh it covers at the beginning say yes of course you can do like two asterix five and that's multiplication and if you do two asterix together like, like two asterisks, asterisks, five, that's like two of the, it's exponents, how you do exponents. But that's just like covered in the first few lines. That's 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, you might use this.
Starting point is 00:02:06 If 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 unpack to repack, but I don't think you can just pass it to a value or something. Yeah, it's really interesting how you can do that. Also, when you're unpacking tuples and all sorts of interesting stuff there, right? Yeah, you can unpack tuples and lists. And then
Starting point is 00:02:40 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 their way. In Python 3.6, you can use them to build dictionaries as well. So you say curly star star dictionary one comma star star dictionary two close curly, and that creates a dictionary that's basically the union of those two. Wow. Okay. Yeah. The star, the asterisk, they go crazy, just like the underscore. Yeah. So this is actually kind of a hard topic to talk about, but I think it's a good article to review and to make sure you understand where things are going or just bookmark it
Starting point is 00:03:20 so next time you're confused by somebody else's code, you can go look at what they're doing. Yeah. That's a good article by Jayay hunter i like it yeah one of the things that i've actually learned from him i think is the the way to um this is i think it's a three six thing where it came in where um you can in your parameter list a 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 keyword. You can't pass them in positionally. They have to be keyword arguments. So yeah, that's really nice because if you, you can name the arguments or you could use positional ones, or you could add the star star kid of yards thing.
Starting point is 00:04:03 But this means, you know, you have basically, you can say you can take a regular argument list and turn it into required only keyword arguments by putting the star as one of the parameters, which is non obvious, but very cool. Yeah. You don't want to know what framework is really awesome that uses that as a core feature in it. No. Responder.
Starting point is 00:04:23 The responder web framework from Kenneth writes, 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? Yeah. 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. A week or so.
Starting point is 00:04:43 Yeah. So what that means is it already has like 1,300, 1,400 GitHub stars because it's Kenneth's work and it's been out for like a week and a half. Yeah. Which is pretty cool. So very popular. And it's sort of the website, the server side equivalent of his request 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.
Starting point is 00:05:08 Okay. 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 to put together a sweet API. It has class-based views without inheritance. It's naturally first an asynchronous web framework, so it supports async and await, and it comes with an ASGI web server,
Starting point is 00:05:32 so you can just run it, and it will start processing asynchronous requests, whereas Flask and those things don't have that yet. So that's a pretty big thing because it's easy to support WebSockets. 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 I have a blog or an ordering system, and then I want to plug that in as a sub part of this, I don't have to rewrite that.
Starting point is 00:06:00 I can just mount that as a URL and anything in say under slash store goes to that implementation and the rest is this new app so that's a pretty cool feature right yeah it also makes it so you can split up the responsibility of maintenance and stuff yeah it's very 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 do it in infrastructure. You can do it in your Python code. It has a background task support, GraphQL, OpenAPI, schema generation,
Starting point is 00:06:37 which is cool, SPA, single-page app support. Let's see. It's built on top of UVicorn, which is one of the faster async IO loops, like UV loop 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. Yeah. And a lot of them are building on top of what other people have learned. And so it's okay to keep rolling out new ones.
Starting point is 00:07:09 Yeah, so one of the things, you know, maybe you'd like this a little better, Brian. One of the things with Flask is it has this 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. Yeah. Which means it's a little harder to test, right?
Starting point is 00:07:26 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 star comma, and then all the values that go into the route, like slash curly variable name, those just become keyword arguments using exactly that thing you were talking about. Oh, nice.
Starting point is 00:07:46 That's cool, right? Yeah. Anyway, so if people want to see what Ken is up to with this web framework, it seems like it's getting some traction. That's pretty cool. And even though it's just started, he's got a built-in test client for it. So that's cool. Yeah.
Starting point is 00:08:01 I'll have to check that out. Yeah, absolutely. All right. What's your next one you got? Let me see. It's down the line. Just a it's hiding 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 anyway pythonprogramming.in and And they were looking at referencing the pandas examples, but it's got a lot more.
Starting point is 00:08:29 It looks like kind of a tutorial on Python. And then so it has just short descriptions and actually short or no descriptions, just really short. Titles, basically. 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.
Starting point is 00:08:50 So it's teaching just through code and examples for the most part. But it goes through, like, starts out with Python basics and then date times and strings and dictionaries. But then quickly jumps into pandas, matplotlib, and then even TensorFlow. 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. Yeah.
Starting point is 00:09:17 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. That's a good point. Yeah, that's nice because you maybe don't know when you're new. Yeah. How do I Google this? I want to do this thing.
Starting point is 00:09:34 I just know I have this problem. How the heck do I solve this? Yeah. Yeah. That's 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 because it goes through all the basics of the language and then Pandas, Math, Plotlib, and
Starting point is 00:09:50 TensorFlow. Yeah, it's like a total deep end crash course, but pretty nice looking and it's cool. Awesome. Oh, that looks like a great resource, especially for people learning data science. I know that's one of the hot areas and a lot of people are getting jobs there. And so that's awesome. What do you got for us? 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 TalkPython. We will see. But first, I want to tell you about Kubernetes over at Digital Ocean. So Digital Ocean has now announced their Kubernetes cluster and support. So for as little as $5, you can spin up a droplet, their terminology for a virtual machine, and it comes pre-configured to be a Kubernetes cluster.
Starting point is 00:10:36 So if you want to work with Docker and group this stuff with Kubernetes and just get rolling with things like zero downtime, 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 at pythonbytes.fm slash DigitalOcean and get started. And if you're a new user there, you get $100 credit to play with Kubernetes and other things as well. Nice. Yeah, they also have GPU based systems and high compute stuff if you want to do data science over there. So that's pretty awesome. The next thing that I have has to do
Starting point is 00:11:10 with Sweden, actually. With Sweden? Yeah, with Sweden. Sweden's pretty awesome. 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, hence Sweden. Oh, okay. Right, because that's who hands out the Nobel Prize. And interesting. Okay, so they're economists. They won the Nobel Prize.
Starting point is 00:11:35 It was Nordhaus and Romer. They basically designed 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 pretty sure it's romer yeah romer is uh become a python and jupiter convert and doing his work and his publishing for his nobel prize with jupiter and python oh that's so cool and that's sweet yeah so first of all the guy is 62 years old and he's just switched to python which is awesome yeah that's great so he said he believes that research should be transparent, and he really thinks it's important that it's open and reproducible.
Starting point is 00:12:28 And like most academics, he worked in some other closed, ultra-expensive thing. So he worked in Mathematica, right? Mathematics is when he's paid things. And he said he tried to share his work, 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
Starting point is 00:12:51 also having Mathematica, the paid version. Oh, yeah. That's lame. Yeah, it's totally lame. So he has some pretty interesting comments. He says he believes the open source notebooks
Starting point is 00:12:59 are the way forward for shared research. And he believes they support integrity while proprietary software encourages secrecy. And he went so on to say, quote, the more I learn about proprietary software, the more I worry that objective truth
Starting point is 00:13:16 might perish from the earth. He wrote so. How's that for a statement? That's pretty wild. So anyway, there's 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,
Starting point is 00:13:35 but the people on the team that did the research, like the leaders of some of the teams there on TalkPython way, way back. And I'm going to link to that. I think it was episode 29 about Stern. That was pretty awesome. Yeah. That was a great episode. Yeah, thanks. It's one of my favorites. And I'd like to actually hear more about people.
Starting point is 00:13:52 It's neat seeing this in economics. I'd like to hear more about people using Python in economics. Yeah, yeah. I mean, I might send them a message and say, hey, if you got the time, I'm sure you're busy. But, you know, come on the show. That'd be awesome. All right. What's your next one? Speaking of science, so that last link we had had some
Starting point is 00:14:09 basics of TensorFlow, but if you really want to jump into it, we've got, there's a Git repo, a GitHub repo that has a simple and ready to use tutorials for TensorFlow in a whole bunch of different, in the repo. So you can kind of get started and get kind of deep into it with some open source examples. So that's what I have to share, really. Nice. You know, I feel like I really just need to take some time and learn some of the AI machine learning stuff.
Starting point is 00:14:37 It's really interesting. It seems super approachable. It's just, 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. 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. Yeah, you probably can. You know, the folks over at Netflix, they use machine learning to analyze and watch
Starting point is 00:15:08 all of their servers because they have too many for humans to understand. And basically, the system knows when it's broken before they do. Yeah. Yeah. So, that's pretty awesome. So, maybe it works for radios as well as servers. Yeah, maybe. That'd be cool.
Starting point is 00:15:22 Possibly. So, the final thing is uh 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 31 more days but probably the time it ships maybe 28 days who knows something like this is this thing called makerphone have you heard of this? I have. It's pretty darn cool. 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 handheld, almost like a Nintendo NES that you could program with super basic graphics. It was pretty interesting. Yeah. The problem was that you
Starting point is 00:16:02 programmed in C. What this is, MakerPhone is a smartphone with a screen that you program in Python. Well, yes, it's super cool. Smartphone is a little bit of a stretch. Yeah, smartphone in quotes. Yeah, it's not super smart, but it does have a screen. I don't think it has a touchscreen, but it has a screen and a little keypad. Yeah. And also, I like this one because you can basically choose your level of commitment to the DIY do it yourself aspect.
Starting point is 00:16:30 You can back the Kickstarter at a level that will get you just the true experience. Here's the boards, here's the wires and the soldering go to town on these instructions or like a little tiny bit more. You can get it assembled so you could just write the software yeah that's pretty cool yeah so i actually back this at the software level because i'm busy i can't i can't be 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 that's pretty cool you backed it i can't wait to see it i was thinking about about it. One of the neat things about that, we've watched the video, some of the belief of the, 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, yeah, learning how to solder parts together, learning how to program stuff, getting all this working and in with like a web page 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.
Starting point is 00:17:33 I mean, we don't have RadioShacks anymore, so people have to do these maker things to figure out some of this stuff. 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,
Starting point is 00:18:02 where she can kind of drag and drop you some stuff together and put like a silly dropdown and 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 Banks game or something on this phone, and I bet you'll love it. We'll see. That's the goal anyway.
Starting point is 00:18:17 Yeah. And even if you already have it pre-built, I'm sure you could take it apart and look out what's inside and everything. Yeah, absolutely. So, this, and it'll be for sale afterwards. They made that NES-like thing previously, which I talked about. That's still for sale. Not too expensive.
Starting point is 00:18:33 So one of the things about Kickstarter is, will the thing actually become a reality, right? They put it, you know, this one, it was the goal has to be $15,000 in order for them to do it. Yeah, they hit that right away. 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.
Starting point is 00:19:00 I just think this is super interesting. The Python angle is awesome, but I bet it hits half a million. Yeah, it's pretty neat. 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 this for a while. He's now 20.
Starting point is 00:19:17 Isn't this cool for a guy who's 20 to be doing this? Well, it is. And that's one of the 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. Yeah. There's a good chance it won't be Vaporware because he's selling the previous Kickstarter thing. Yeah. Yep. Pretty awesome. Well, I'm excited to get mine and build Pong with my daughter. All right. Cool. Awesome. I did want to throw out one more thing really quick. So there's been all this talk about Python 2 versus Python 3, you know, legacy Python, modern Python.
Starting point is 00:19:49 What's going to happen? Well, you know, PHP has something not terribly different going on. Really? There's 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,
Starting point is 00:20:10 but WordPress is so prevalent on the internet that 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 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. Yeah.
Starting point is 00:20:41 Okay. Yeah. Anyway, parallels. Well, that's a show, man. 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 now 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 probably yeah that makes sense it does
Starting point is 00:21:03 all right with you know counting and all that. Talk to you next week. See ya. Bye. Thank you for listening to Python Bytes. Follow the show on Twitter via at Python Bytes. That's Python Bytes as in B-Y-T-E-S. And get the full show notes at PythonBytes.fm.
Starting point is 00:21:20 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 Ocken, this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.