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


Transcript #101: Nobel Prize awarded to a Python convert

Return to episode page view on github
Recorded on Monday, Oct 22, 2018.

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 Atkin. 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 gonna be covering some very very cool frameworks before we get to those though So let's say thank you to DigitalOcean.

00:28 They're sponsoring Python Bytes for the entire rest of the year.

00:32 So that's a huge support from them.

00:34 And we really appreciate it.

00:35 Thank you.

00:36 Check them out at pythonbytes.fm/digitalocean.

00:38 More about that later.

00:40 You seem to be picking a fight with asterisks.

00:42 What's going on here?

00:43 There's a lot of asterisks in your notes.

00:45 I just asterisks.

00:46 Love asterisks.

00:47 No.

00:48 Asterisks, asterisks, asterisks.

00:49 Yeah.

00:50 What do you get in Python if you have four asterisks?

00:51 Come on.

00:53 Seg fault?

00:53 I don't know.

00:53 Anyway, sorry.

00:54 I'm derailing you.

00:55 Keep going.

00:56 (laughing)

00:57 - 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.

01:04 - We covered underscore.

01:05 We covered underscore.

01:07 Right, underscore has so many meanings.

01:09 Parentheses have many, many meanings.

01:11 And asterisks as well, which I think is really interesting.

01:15 Like, Python's pretty light on the syntax in the sort of symbol form, but those three things, they do a lot.

01:21 - They do a lot.

01:22 - And they mean different things, right?

01:23 So take us through this one.

01:24 So this is an article from Trey Hunter, Asterix and Python, what they are and how to use them.

01:31 And 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 two asterix asterix five, that's like two, it's exponents, 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 first one he starts with, you might use this. 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 or unpacking, I don't think you can unpack not as a parameter.

02:25 You can unpack to repack, but I don't think you can just pass it to a value or something.

02:30 Yeah, it's really interesting how you can do that.

02:33 Also, when you're unpacking tuples and all sorts of interesting stuff there, right?

02:37 Yeah, you can unpack tuples and lists.

02:39 And then the two asterisks is to unpack keyword arguments.

02:43 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.

02:51 - And Python 3.6, you can use them to build dictionaries as well.

02:54 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.

03:03 - Wow, okay.

03:04 - Yeah, the star, the asterisk, they go crazy, just like the underscore.

03:08 - 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 so next time you're confused by somebody else's code, you can go look at what they're doing.

03:24 - Yeah, that's a good article by Jay Hunter, I like it.

03:26 - Yeah, one of the things that I've actually learned from him, I think, is the way to, this is, I think it's a 3.6 thing where it came in, where 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.

03:51 You can't pass them in positionally.

03:52 They have to be keyword arguments.

03:55 - Yeah, that's really nice because you can name the arguments or you could use positional launch or you could add the star star KWR thing.

04:04 But this means, you know, basically, you can take a regular argument list and turn it into required only keyword arguments by putting a star as one of the parameters, which is non-obvious, but very cool.

04:16 - Yeah, yeah.

04:17 - You know what I know what framework is really awesome that uses that as a core feature in it?

04:22 - No, what?

04:23 - Responder, the Responder web framework from Kenneth Wright, which is a brand new web framework.

04:28 It's a little bit like Flask, but you know, he has requests, and then what responds to requests?

04:35 Well, Responder responds to requests, right?

04:37 - Yeah.

04:38 - 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:43 - A week or so.

04:43 - Yeah, so what that means is it already has like 1,300, 1,400 GitHub stars 'cause it's kind of work and it's been out for like a week and a half.

04:51 - Yeah.

04:52 - Which is pretty cool.

04:54 So very popular and it's sort of the website, the server side equivalent of his request API.

05:00 And he's trying to make something a little like Flask but more friendly, easier to work with, easier to test, things like that.

05:07 - Okay.

05:09 So let me run through some of the things that it does as its core features.

05:13 It has a pleasant API, which is cool with a single import statement.

05:16 So you know, you would expect Kenneth put together a sweet API.

05:21 It has class based views without inheritance.

05:23 It's naturally first an asynchronous web framework.

05:27 So it supports async and await and it comes with an ASGI web server.

05:33 So you can just run it and it will start processing asynchronous requests, whereas, you know, and those things don't have that yet.

05:39 So that's a pretty big thing.

05:41 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.

05:51 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.

06:00 I can just mount that as a URL, and anything in, say, under /store goes to that implementation.

06:08 And the rest is this new app.

06:09 So that's a pretty cool feature, right?

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

06:14 - Yeah, you could break it up.

06:16 Like one team manages this part, another team manages that.

06:19 But on the server side, it looks like all one thing.

06:23 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.

06:29 You can do it in your Python code.

06:32 It has a background task support, GraphQL, OpenAPI, Schema Generation, which is cool, SPA, Single Page App Support.

06:41 Let's see, it's built on top of UVicorn, which is one of the faster async I/O loops, like UVloop and so on.

06:48 And yeah, it's even got a nice ASGI support, like I said, for async stuff.

06:54 So I don't know if the world needs more web frameworks.

06:57 It feels like we have a lot of these, but I also feel like this is gonna be a massive success, just the way you look at it.

07:03 - 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.

07:10 - Yeah, so one of the things, 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.

07:19 It's just there, like a global variable, but it's thread local or something like this, which means it's a little harder to test, right?

07:27 'Cause how do you mock out that thing properly all the time?

07:29 And this one takes the request and the response, so you can modify the response real easily.

07:35 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.

07:46 - Oh, nice.

07:46 Okay. - It's cool, right?

07:47 Yeah.

07:48 Anyway, so if people wanna see what Ken is up to with his web framework, it seems like it's getting some traction.

07:53 That's pretty cool.

07:54 - And even though it's just started, they've already, he's got a built-in test client for it.

07:59 So that's cool.

08:01 - Yeah.

08:01 - Check that out.

08:02 Absolutely.

08:03 Alright, what's your next one you got?

08:04 Hmm, let me see.

08:05 It's down the line.

08:06 Just a sec.

08:07 It's hiding.

08:08 It's hiding.

08:09 Yeah.

08:10 So I ran across, I actually saw somebody reference this website because the website is pythonprogramming.in.

08:16 I'm not sure what the "in" is.

08:19 But anyway, pythonprogramming.in.

08:22 And they were looking at the, referencing the pandas examples.

08:27 But it's got a lot more.

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.

08:40 Titles basically.

08:41 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.

08:51 So it's teaching just through code and examples for the most part.

08:53 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.

09:04 There are many, many topics on say pandas, for example.

09:08 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?

09:15 Or at least some sample code.

09:16 Yeah.

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.

09:26 So that's kind of neat.

09:28 That's a good point.

09:29 Yeah, that's nice, because you maybe don't know when you're new.

09:32 Yeah, how do I Google this?

09:33 I want to do this thing.

09:34 I just know I have this problem.

09:36 How the heck do I solve this?

09:37 Yeah.

09:37 Yeah, that's pretty cool.

09:38 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.

09:46 Because it goes through all the basics of the language, and then Pandas, Math, Plotlib, and TensorFlow.

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

09:57 Awesome.

09:58 Well, that looks like a great resource, especially for people learning data science.

10:01 I know that's one of the hot areas, and a lot of people are getting jobs there.

10:04 And so that's awesome.

10:06 Well, what do you got for us?

10:06 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.

10:15 We will see.

10:15 But first, I want to tell you about Kubernetes over at DigitalOcean.

10:19 So DigitalOcean has now announced their Kubernetes cluster and support.

10:25 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.

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.

10:51 So check them out at pythonbytes.fm/digitalocean and get started.

10:55 And if you're a new user there, you get $100 credit to play with Kubernetes and other things as well.

11:00 Nice.

11:01 Yeah, they also have GPU-based systems and high compute stuff if you want to do data science over there.

11:07 So that's pretty awesome.

11:08 The next thing that I have has to do with Sweden, actually.

11:12 With Sweden?

11:13 Yeah, with Sweden.

11:14 Sweden's pretty awesome.

11:15 I haven't got to spend much time in Sweden, but I definitely like the place.

11:19 And the news is there's these two American economists who have won the Nobel Prize in economics, hence Sweden.

11:28 - Oh, okay.

11:29 - Right, 'cause that's who hands out the Nobel Prize.

11:31 And interesting, okay, so they're economists, they won the Nobel Prize, 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.

11:49 So it's basically like a theory of the welfare of the world's population and economy, which is pretty cool.

11:55 But why am I talking about it?

11:56 Because one of the guys, I think Rahmer, pretty sure it's Rahmer, yeah, Rahmer, is become a Python and Jupyter convert and doing his work and his publishing for his Nobel Prize with Jupyter and Python.

12:11 - Oh, that's so cool.

12:12 - Isn't that sweet?

12:13 - Yeah.

12:14 - So first of all, the guy is 62 years old and he just switched to Python, which is awesome.

12:19 - Yeah, that's great.

12:20 - So he said he believes that research should be transparent and he really thinks it's important that it's open and reproducible.

12:28 And like most academics, he worked in some other closed, ultra-expensive thing.

12:33 So he worked in Mathematica, right?

12:35 Mathematics, when he's paid things.

12:36 And he said, tried to share his work, right?

12:40 This Nobel Prize winning work, he tried to share it.

12:42 And he said he couldn't do it.

12:44 Wolfram Research, who makes Mathematica, Basically made it impossible to share his research without the people receiving it also having Mathematica the paid version. Yeah Yeah, that's lame. Yeah, it's totally lame. So he has some pretty interesting comments He says he believes the open source notebooks 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 might perish from the earth He wrote so That for a statement. Yeah, that's pretty wild. So anyway, there's a short article you can check it out Actually the links to a bunch of his blog posts and his writings from dr. Rahmer. 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 gonna link to that. I think it was episode 29 about sir. That was pretty awesome Yeah, that was a that was a great episode. Yeah, thanks That's one of my favorites 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 and economics. Yeah. Yeah I mean, I might send him a message and say hey if you got the time, I'm sure you're busy But you know, yeah, come on the show. That'd be awesome. All right. What's your next one speaking of science?

14:06 So that last link we had had some basics of TensorFlow, but if you really want to jump into it, we've got a Git repo, a GitHub repo that has simple and ready to use tutorials for TensorFlow in a whole bunch of different, in the repo.

14:22 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.

14:32 I feel like I really just need to take some time and learn some of the AI machine learning stuff.

14:37 It's really interesting.

14:39 It seems super approachable.

14:41 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.

14:48 - Yeah, I definitely agree.

14:50 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:03 - Yeah, you probably can.

15:03 - Yeah.

15:04 - 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 humans to understand.

15:12 And basically, the system knows when it's broken before they do.

15:15 (laughing)

15:17 - Yeah.

15:18 - Yeah, so that's pretty awesome.

15:19 So, maybe it works for radios as well as servers.

15:20 - Yeah, maybe.

15:21 That'd be cool.

15:22 - Possibly.

15:23 So, the final thing is something that people might actually be super interested in being part of.

15:29 and it's gonna 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 Maker Phone.

15:41 Have you heard of this?

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

15:44 - So Maker Phone is from this guy named Albert in Croatia, and he had made something previously, and what was it called?

15:52 I can't remember.

15:53 It was like a little handheld, almost like a Nintendo NES that you could program with super basic graphics.

16:00 It was pretty interesting.

16:01 The problem was that you programmed in C.

16:03 What this is, Maker Phone is a smartphone with a screen that you program in Python.

16:11 - Well, yes, it's super cool.

16:13 Smartphone is a little bit of a--

16:15 - Yeah, smartphone in quotes.

16:16 Yeah, it's not super smart, but it does have a screen.

16:19 I don't think it has a touch screen, but it has a screen and a little keypad.

16:23 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.

16:36 Here's the boards, here's the wires and the soldering, go to town on these instructions.

16:42 Or for like a little tiny bit more, you can get it assembled so you could just write the software.

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

16:50 - Yeah, so I actually back this at the software level 'cause I'm busy.

16:53 I can't do soldering stuff.

16:55 I would like to, but I'm afraid I'll just not do it.

16:58 I'd rather just try the software side.

16:59 - That's pretty cool that you backed it.

17:00 I can't wait to see it.

17:01 I was thinking about it.

17:03 One of the neat things about, if you watch the video, some of the belief of the, I guess it's a small company around this, is that it isn't to try to get you a cheap phone.

17:12 It's to help teach people.

17:15 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 with a web page that'll walk everybody through whatever they need to do with it.

17:29 And that sort of thing is neat because it's missing out of a lot of places.

17:33 I mean, we don't have Radio Shacks anymore, so people have to do this maker things to figure out some of this stuff.

17:39 - Yeah, it looks really, really fun, and I'm excited to do it.

17:42 You can program it in Scratch or Python.

17:46 It's also Arduino-based, so you probably can program it in C++ as well.

17:50 I'm excited.

17:51 The reason I got it is my daughter is really into making websites with Python, like simple, super super simple ones with say Anvil, where she can kind of draggy drop you some stuff together and put like a silly drop down and a picture or something.

18:07 You know, something really simple.

18:08 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'll love it.

18:16 We'll see.

18:17 That's the goal anyway.

18:18 Yeah.

18:19 - I already have it pre-built.

18:20 I'm sure you could take it apart and look at what's inside and everything.

18:23 - Yeah, absolutely.

18:24 So this, and it'll be for sale afterwards.

18:27 They made that NES-like thing previously, which I talked about.

18:30 That's still for sale, not too expensive.

18:33 So one of the things about Kickstarter is, will the thing actually become a reality, right?

18:38 They put it, you know, this one, it was, the goal has to be $15,000 in order for them to do it.

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

18:46 - 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.

18:53 So I bet this thing hits half a million.

18:55 Especially now that we covered it on the show.

18:58 I mean, they didn't pay us anything.

19:00 I just think this is super interesting.

19:01 The Python angle's awesome.

19:02 But I bet it hits half a million.

19:04 - Yeah, it's pretty neat.

19:05 - What's crazy, Brian, is this guy did the first project when he was, as a Kickstarter, when he was 18.

19:11 I didn't bother to look, actually, what that brought in.

19:13 Now he's much more mature.

19:15 He's been working this for a while.

19:16 He's now 20.

19:17 Isn't this cool for a guy who's 20 to be doing this?

19:19 - Well it is, and that's one of the neat things about this project also is that it's not his first project.

19:25 So now that you've done it, you gotta actually build it.

19:27 He's already done that.

19:29 - Yeah, there's a good chance it won't be Vaporware 'cause he's selling the previous Kickstarter thing.

19:33 - Yeah. - Yep, pretty awesome.

19:34 Well, I'm excited to get mine and build Pong with my daughter.

19:37 - All right, cool.

19:39 - Awesome.

19:40 I did wanna throw out one more thing really quick.

19:44 So there's been all this talk about Python 2 versus Python 3, legacy Python, modern Python, what's gonna happen?

19:50 Well, PHP has something not terribly different going on.

19:54 There's this article, I'm just gonna read you the title.

19:57 I think it's overgeneralizing.

19:59 Anyway, the title is, Around 62% of all internet sites will run an unsupported PHP version in 10 weeks.

20:06 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 that's probably not a super big difference.

20:16 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 at a date as well.

20:28 So it's just an interesting article, I'll throw it out there.

20:31 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 Yeah, okay.

20:41 Yeah, anyway, parallels.

20:42 Well, that's a show, man.

20:44 It's definitely a show.

20:45 And we are into triple digits properly now with 101.

20:50 So what's the next one, 201?

20:51 I guess, was this a prerequisite for the next one?

20:53 You know, what's the--

20:54 (laughing)

20:56 Nah, it'll be fun.

20:57 It's been great to do it, and we're gonna keep cranking out.

20:59 It'll be 102, I suppose.

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

21:03 - It does.

21:04 - All right.

21:05 - With, you know, counting and all that.

21:06 - Talk to you next week.

21:08 - See ya.

21:09 - Bye.

21:09 - Thank you for listening to Python Bytes.

21:11 Follow the show on Twitter via @pythonbytes.

21:13 And that's Python Bytes as in B-Y-T-E-S.

21:17 And get the full show notes at pythonbytes.fm.

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

21:25 We're always on the lookout for sharing something cool.

21:27 On behalf of myself and Brian Okken, this is Michael Kennedy.

21:31 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page