Python Bytes - #231 Go Python, Go!

Episode Date: April 28, 2021

Topics covered in this episode: For-Else: A Weird but Useful Feature in Python Tortoise ORM Faster Python with Go Shared objects Learn by reading code: Python standard library design decisions expl...ained (for advanced beginners) Gradio: Create UIs for prototyping your machine learning model in 3 minutes Use basketball stats to optimize game play with Visual Studio Code Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/231

Transcript
Discussion (0)
Starting point is 00:00:00 Hello and welcome to Python Bytes. This is episode 231, recorded April 28th, is that right? Yeah, 2021. I'm Brian Ocken. I'm Michael Kennedy. I'm Cecil Philip. Yay. Hey, welcome Cecil. Hey, thanks for having me on. It's always good to come back on this podcast. This, you know, unbiasedly is probably one of my favorite podcasts to listen to, to be honest with you. Mine too, yeah. Thanks so much. We get to learn so much stuff by studying and just getting ready for each week. And it's always fun to just see the new and exciting. Developers, we love the shiny new things, right?
Starting point is 00:00:35 Yeah. Absolutely. Well, before we jump into the topic, I thought maybe we could let Cecil introduce himself real quick. I know you've been on the show before, but it's been a little while. Yeah, it has been a little while since I've been on. But hi everyone, I'm Cecil Phillip. I'm a cloud advocate at Microsoft. And that pretty much just means I spend a lot of time in the community working with different companies and students and just really creating content around how
Starting point is 00:01:00 a developer can start using our tools. One of the things that I do, Michael's showing you one of the things that i do michael showing you uh you know one of the pages from our channel nine video site i help run the on.net show um it's not python um but it is.net and we do talk about you know just a lot of different things in the ecosystem so about you also do python stuff on some live stream on twitch and so on right just not on the official.net channel yeah yeah, yeah, yeah. So we do do, the live streaming stuff happens on Twitch and YouTube. And you could always go back
Starting point is 00:01:29 and check out the recordings of those too. Really quickly before we jump to Brian's item, I do want to point out on the screen that's top level statements that C Sharp has added, which is like, let's be more like Python. I think that's kind of interesting thing, right? I think with the last set of, like in C Sharp has added, which is like, let's be more like Python. I think that's kind of an interesting thing, right? I think with the last set of, like in C Sharp 9,
Starting point is 00:01:48 a lot of the things that came out of the last language feature set, everyone is just like, this looks a lot like Python. This looks a lot like Python. Wait till.NET 6 and C Sharp 10 come out,
Starting point is 00:02:00 then I'll have to see what you say there. We're going to use the def keyword and all that. Typing's optional. Got it. I mean, I don't know. We'll see. We'll see what happens.
Starting point is 00:02:09 So I might have to check out C sharp again if it gets close to Python. I mean, it's not a bad time to jump in. Yeah. Yeah. Definitely one of the better languages out there. I certainly think so. All right, Brian, take us away. What's your first item here?
Starting point is 00:02:21 Are you going to tell us or else what? Yeah. Or else. away what's your first item here are you going to tell us or else what yeah um or else so um i actually was intrigued by this because this is that's a article called the basic well what's the article called uh for else a weird but useful feature in python plus there's a cute avocado stuffy um but there's um uh i'm not used to using else or break in my Python code. Um, I just don't do it that much. So the, um, yes, hello birds. Um, so the, this is an interesting, uh, interesting article, um, about, about the else block. And what it does is
Starting point is 00:03:05 if you've got a for loop and there's no break inside of it, well, then your else will get hit. So the only way to use else effectively is to maybe have a break so that you at some times don't hit it. So it's still a little confusing to me.
Starting point is 00:03:23 So I was reading more. The article goes on about talking about some examples where you'd want to do it. So it's still a little confusing to me. So I was reading more. The article goes on about talking about some examples where you'd want to do it. And it does explain, it explains it way better than I just did. So if you're interested about that, read the article. But the explanation of why you would use it, my favorite is if you were going to iterate to find an item, um, and, and you would normally maybe use a found flag or something to say that you found it. You don't need to with this. You can, you can, uh, once you find the item, you can break, um, and then the, and then you hop out and the else block will only get, um get run if you did not find the item. So that's really pretty much the use case that I think is neat.
Starting point is 00:04:09 Yeah, I agree with that one. And I love the break out of these loops early, you know, because we end up so often with super indented code, right? It's like, if this is true and if this is true and if this is true and you could put those into a couple of breaks or continues in your loop and then, oh boy, it's nice and flat-ish. Yeah. The other, one of the other use cases he brought up was,
Starting point is 00:04:32 was using it with an exception. So if you've got an exception, try accept block within a for loop and, and you kind of want to know outside whether or not any exceptions were caught you can use the else block to find out if you if any man i can't get behind that like i know that's the use case try this else i can't get behind it it's just it's too it's too weird for me uh to think about i i would i just never use it because it just seems a little unusual and i i know i've
Starting point is 00:05:06 talked with some folks on the internet they're like oh but this is a way to add like a continuation to your try block that you won't over catch errors and i'm yeah i don't know i hear you but i but this this else one on the loop i could i can see this is a you know not too bad compared to found flag and then what i want to express uh before we leave this is if you're not too bad compared to found flag and then what i want to express before we leave this is if you're going to either put a i think both break or else if that's in your code there should be a comment explaining what it does because there's a lot of python developers that won't know what's going on so yeah so what do you think yeah i i actually really like both of them like both the four the four else and the try else, only
Starting point is 00:05:46 because I think about how much code would I have had to have written otherwise, you know what I mean? For me, it just kind of makes those situations a little bit more succinct. And I completely understand what you're saying, because a part of me also on the other half is like, well, I could just put the rest of the code inside the try block, right? And then, you know, obviously there's no exception, we'll just keep running, right? That's just put the rest of the code inside the try block, right? Yeah, exactly. Whatever the else is, that's just continue on. Exactly, exactly.
Starting point is 00:06:09 Yeah, like my continuation happens in the same block of code. So I completely understand it from that perspective too. So I don't know. I guess I'm kind of 50-50 on it. I kind of like it. I'm like, well, we could do it another way. So I don't know. Yeah.
Starting point is 00:06:21 And just jumping back a tiny bit, Dean has a bit of foreshadowing for you in the live stream john posted in 2022 looking for pie sharp developers with 10 years of experience wow and rob is out there uh giving a shout out to brian's birds i don't know how accurate that emoji is but it looks pretty legit that's pretty good yeah we got i got three here. Nice. All right. I think I got the next one, right?
Starting point is 00:06:47 So let's talk. You were done with this one, right? And I didn't steal it from you? Yeah, and I'm going to step out and cover the birds. Okay. I'll tell you about the ORM while we're doing that. So probably the two most popular ORMs we have out there are Django ORM,
Starting point is 00:07:03 which really only makes sense if you're actually doing Django, or SQL Alchemy. And those are both really interesting, but I want to give a shout out to Tortoise ORM. I think these names are always interesting. Naming things is hard. I always think of databases and database libraries to be awesome if they're fast, and less awesome if they're slow, but tortoise doesn't scream speedy but i think you should think of it more in the speedy side because it's um primarily an async io object relational mapper inspired by django so if you were like i love what django does but what i really want is an async version of that tortoise orm is a really good example and you know it uses the
Starting point is 00:07:43 active record design pattern instead of unit of work, which SQL Alchemy uses. So it's pretty neat. They have a bunch of performance stuff. And I really like that they show the performance against many different ORMs, not just Django and SQL Alchemy, but other ones like Pony and Kiwi
Starting point is 00:07:58 and a lot of different use cases. You can get a sense, like it's pretty fast. It's not raging fast, but it's async. So that's a really, really good option there. Super simple to use. When you install it, you typically need to install the underlying database driver that it's going to use. So if you're going to use it with Postgres, you install async PG. If you're going to use it with MySQL, you install AIO, MySQL, and so on along with it.
Starting point is 00:08:22 But if you look at the code, it's super simple. And if you're familiar with Django, you go and create the fields as members of a class equal to some descriptor like fields.intfield or field.textfield, let them have indexes and so on. What's really nice is there's like really good modeling of relationships. So there's like fields.foreignkey field,
Starting point is 00:08:44 fields.many2many field, fields.minitominifield and it talks about the relations and so on. So yeah, this is a really nice RM. If you're looking for something async that is like Django, give this a shot. It's pretty popular. It has almost 2,000 GitHub stars. It was updated two days ago.
Starting point is 00:08:59 So yeah, it seems like a nice, happy project. This looks pretty cool. When you were showing that installation section just now, so you still have to install like the async versions of, I guess that particular database's driver. So async MySQL, async Postgres, and things of that nature. So I'm guessing what this adds,
Starting point is 00:09:17 kind of like what you said, is that active record programming model, right? Like, so if you want to write your code in that style, you know what I mean? I can write it and then now I could just switch swap out the the database driver and i could point to a different database implementation if i wanted to yeah exactly i think it does two two things one is there's always like database dialects like how do you express parameters question mark or at parameter name or whatever right i think it handles that and then a lot of those drivers
Starting point is 00:09:43 they're they're async but they only work in raw SQL. So select star from such and such, and so on. And so this just gives you the ORM wrapper on top of it. But I think it does this dependency thing because otherwise it would have to install every driver it supports.
Starting point is 00:09:59 Sure. And that would be a hassle, right? Because you only want one. Yeah, that would be a little messy. Yeah, why does it take so long to install? Well, it's installing every database driver it can think of. No, this is, that would be a hassle, right? Because you only want one. Yeah, that would be a little messy. Yeah. Why does it take so long to install? Well, it's installing every database driver you can think of. No, this is pretty cool.
Starting point is 00:10:09 I like it. Brian, what do you think? Actually, I think it's pretty great. And I was actually starting to look at an ORM for a new project. So I might check this out. Yeah, I like it pretty well. It's got some really simple ways to program it.
Starting point is 00:10:22 You can create one of these objects and then you just await tournament.save if it's a tournament in this case, or it has like a factory sort of create method for queries. You go do some kind of query and then just await a class.filter type of thing and even does like the join so you don't end up with the N plus one performance problems.
Starting point is 00:10:42 One thing I guess I would throw out there is it seems to me like this is 100% async. So if you're going to use it, you have to create an event loop and just run it in there. And if your app is not very asynchy, then it might be kind of a hassle to use. I'm not totally sure about that. It used to be that there were these wrappers you could get that would take non-async libraries and database libraries and stuff and make them async by putting them on threads. I can see a world where we get back to wrappers that make them sync so they're easier to use if you
Starting point is 00:11:08 don't want to do async yeah i know one of the things for me that's always been a little challenging is when you have like these async database things like how do i how do i test them you know what i mean i always find like testing at least when it when it comes to unit testing testing um async io things is relatively non-trivial. You know what I mean? Yeah. Like I have a thing that uses motor, like so the MongoDB async library, and I'm using it in FastAPI.
Starting point is 00:11:35 And you know, FastAPI does this injection thing. I'm like, oh, great. My code is clean because I'm, you know, I'm separating concerns and I'm doing all this thing. Man, like how do I test this thing? Like how do I- Brian, do you do I stub out, mug out this thing? Brian, do you got any advice on testing async things? Well, I don't right now, but I think that'd be a great topic to explore and try to get
Starting point is 00:11:53 some people on the podcast. Yeah, I agree. Yeah, that'd be great. If you ever write part two of your book, I'd love to see it. Well, there's a second edition coming out, but it doesn't include async. It hasn't published yet, has it? There's still time for another chapter there you go there you go but um uh jumping back uh i did see that uh brett cannon had an interesting uh comment about uh the else clause one of the benefits is that hey bro makes you look like a Python expert in code reviews when
Starting point is 00:12:26 you suggest people use it. So I think that's funny. Yeah, that is funny. Yeah. A lot of thoughts here on the else clause. I do think it's one of these things. It's a little unusual. Like a lot of languages have like, oh, we all have the while loop. We all have the for loop. We all have the statements. They all look like this. And this is kind of a little bit different. So it's kind of interesting. All right. Cool. Cecil, you're up next, right? Yeah, I am. So I ran into this post about faster Python with Go shared objects, which I thought was a really interesting read. Mainly for me, I'm really into like language interop, right? Like the fast part is cool when I get it. Like fast is always a relative thing that we could consider. What do we really consider to be fast or not? But, you know, it's always interesting
Starting point is 00:13:09 for me to see how we can take one language and another and kind of plug them together. You know what I mean? Because I'm a big believer in let's, you know, let the thing do what it's best at. You know what I mean? Like, so for instance, Python's really good at doing certain things. Let Python do that. Or Go is really good at doing certain things. Let Python do that. Or Go is really good at doing certain things. Let Go do that. But now, how do we plug these worlds together? And so this article kind of goes through talking about how within Go, you can create these things called shared libraries. And I believe what it does is that it outputs a.so file or a.dll file.
Starting point is 00:13:41 And then based on that in Python, you could use something like c types or this article actually even references something called cffi i've never heard about cffi i don't know if y'all have spoken about it before yeah it's a more modern interop layer between c libraries yeah i think they mentioned so yeah yeah right there yeah so it mentions using things like cffi for instance to be able to load some of these files and do interrupt, which I think is actually pretty cool. You know, it does also talk about some of the pros and cons, which I think are very important to discuss. So for instance, this says, well, it's really good if you're just passing around like primitive
Starting point is 00:14:16 types. But now when you want to pass around like more complex types, like, you know, dictionaries and classes and things of that nature, then it becomes a little bit more tricky to do. But, you know, again, just in terms of, hey, I have this thing that I want to pass on to Go to maybe, I don't know, maybe Go runs it in the background or, you know, runs this microservice thing that, you know, does Docker and Kubernetes or whatever the case is, you know, we could leverage both ecosystems to, again, have them do what they're good at and kind of like just plug them together, which I think this is a pretty cool read. I'd love to hear what folks think about it after they read through it. Yeah, I think it looks really interesting. You know, one of the
Starting point is 00:14:52 powers of Python is this interoperability, mostly around C, but also other things like weird things like Fortran and so on, right? Like people say, oh, well, doing math with Python is super slow relative to C++ or whatever. And yet data science is so popular where it's almost all math, right? How do you square these two things? Like, how do you make them work? And it's because a lot of that gets pushed down into some more native layer, like a C layer. You just hand off the data and then zip it.
Starting point is 00:15:20 The real work happens there. And this seems like another really cool way to do that, right? Something that works really well in Go, write a package, wrap up the Go bits, put them in a wheel, pip install them, and people don't have to know. It's also not just what the language can do best.
Starting point is 00:15:36 It's what the developers can do best. And if you've got somebody that's really good at Go working on part of the problem, being able to connect them together is a good idea. I think that we're far away from the time where people just had one language that they knew anyway. And I don't know if we ever were there, but definitely early in my career,
Starting point is 00:15:59 there were some C and C++ developers that that's all they knew, a little shell scripting, but I don't find that anymore. And I think most Python developers know some other language as well. Yeah, like CSS, they typically program in CSS. That's just the bad, that's what the bad surveys ask. No, but you're right. And it's also not just about knowing the language. It's about, well, we spent two years building this other library and it works.
Starting point is 00:16:24 Can we just use that over here? Like this interop for just reuse is really powerful as well yeah definitely yeah i always found when i was growing up you know when i went through college you know my professors always told me any good programming uh good programmer knows like three or four different languages like that's you know what they kept drilling into us and it's funny we always talked about learning different languages but we never ever spoke about putting them together. You know what I mean? And kind of like what you were saying, I feel like that's kind of where we are. No one knows one language. No one that works in a company in a really productive ecosystem does one thing. You probably know some JavaScript and some Python and some, you know, Go and Rust and SQL and like there's stuff in there.
Starting point is 00:17:07 But how do we put that stuff together in a very clean and like maintainable way? Yeah. Another thing, you know, thinking back to the times when we were all in college, so much of what we did was like really low level, like, oh, I need to load this file. So I got to write the binary bits to parse this file, right? It was like super low level and it took a long time. And these days it's more about Lego blocks.
Starting point is 00:17:29 Get this thing, that thing, click them together and make that piece go over there, right? And this whole interop for that is also, you know, makes sense in that world. Yeah. Well, we have some,
Starting point is 00:17:41 you have some cool, I want to plug your stuff so we don't have a sponsor so we'll plug you yeah okay so yeah thanks man i appreciate it yeah were you let me i'll be specific about something something that i think if you dug through the course catalog there's a little coming soon graphic but people probably don't know is we're about to release a course on dask so dask is a way to do like pandas type stuff But if it needs to load 10 terabytes of data and that won't fit even on your hard drive, or you want to run it across, you know, 16 cores on your machine, across 10 machines,
Starting point is 00:18:13 you just write pandas code, but you point it somewhere else. And it just parallelizes that beautifully with this cool little dashboard. So anyway, there's a free course coming on Dask that people will be able to take really soon. That'll be fun. No, it's good. I think everybody should check out your course catalog. And one of the best things that happened to the Python community was when you quit your full-time job and started working on this full-time. Thanks. A short four or five years ago.
Starting point is 00:18:37 I would definitely concur with that. I'm curious about Dask too, because I remember you all speaking about in a previous podcast and i always wondered oh wow is this only for pandas or can i use das to just run remote python anywhere i wanted to i think you can actually i do think you can make it run remote python um the simple use case is sort of import something different that looks like pandas and use it you know but i think there's a way there's like a lower level sort of import something different that looks like pandas and use it, you know? But I think there's a way, there's like a lower level set of libraries that do that orchestration.
Starting point is 00:19:09 You probably could use it. I'm trying to remember and make sure that that's the right one. But I think that's what Matthew Rocklin pointed out when we were talking about it. So yeah, quite cool. Yeah, because that would make, for me, makes Python really interesting from a distributed systems perspective.
Starting point is 00:19:22 Yeah. Again, we think about like containers and multiple VMs and even just talking across boundaries of networks right yeah yeah and just being able to import my library and run it you know what i mean yeah absolutely super cool all right brian you got the next one yeah so uh speaking of learning uh to code um uh you know as you go on with your learning to code, there's tutorials and stuff, but then you want to get into really finding out how things, people are really solving problems all over the place. And a great discussion around that is to, and good recommendations, is to just go read some code. You need to read a lot of code. And there's problems with that,
Starting point is 00:20:01 though. And so this is an interesting article I'm going to link to. Learning to read code, Python standard library design decisions explained for advanced to beginners. That's an interesting term, advanced beginners. But so there's an interesting discussion around this. So the standard library is there. So that's a great thing to go look at. It's available and all of it's there so you can read all of it but there's some interesting caveats and some in uh both good and bad so there's pros and cons one of the pros
Starting point is 00:20:32 is all the peps are around so you can read the design decisions of why why things are the way they are and and some of the history and what problem they're trying to solve that's actually an incredible benefit because i don't even get that with internal code often with a company. It's often just the code that was left to me that I have to maintain. So this is kind of neat. And usually it was done just enough to work
Starting point is 00:20:56 and then we're done with it. Yeah. And Python gets to improve on itself, which is nice. The downside is there's a lot of it and a lot of it's really old. So there's some code in there from 10 to 20 years ago. And there's what's Pythonic now might not have been Pythonic then. So maybe not best practices. I don't know this firsthand, but this is a comment from the article.
Starting point is 00:21:22 So I think that's fair. And also, you don't really want to learn uh this isn't necessarily from the python standard library but just picking some thing that you use on the on github it could be incredibly useful that doesn't mean that it's coded well though so it might not be a good example for coding um so the the author has uh three three or four just uh uh different standard libraries that he recommends um which is pretty interesting uh the statistics module uh he says it's the the code is simple and it's a it's fairly well documented and the pep i think it's also
Starting point is 00:21:59 pretty new which is kind of a oh really good i think i'm not sure when the statistics that but it was added it didn't come originally. It's been added after a while. But there's other things around that people use for statistics. So the PEP apparently talks about design decisions about not trying to re-implement NumPy or something like that within the standard library,
Starting point is 00:22:22 but just have basic statistics. 3.4, by the way, is when statistics showed up. Oh, yeah. So it's not that old, right? Yeah. And actually, the next two are fairly recent as well. Pathlib is recommended because it's extremely well documented. And it's a good object-oriented example.
Starting point is 00:22:44 There's not a lot of object-oriented examples out there in Python because a lot of people don't use it. So that's good. Also, a nice comparative study because we already had OSPath. So you can look at how OSPath solved it versus Pathlib solving the same problem. That's kind of neat. Data classes is apparently very well documented. And I'm not sure what else I was going to say because I wrote down it's a good example of data classes. That doesn't make sense.
Starting point is 00:23:13 It may be the very best example of data classes implementation. Yeah. Or the only. And then GraphLib, which says it's a bonus, but it's interesting because it does one thing. It's an implementation of a topological sort algorithm, which I'm not exactly 100% sure what that is, but it's a narrow problem. And there's no PEP, but apparently there's an issue that the article links to with a long thread discretion. And the interesting thing about this isn't the discussion about how it should be implemented. It's the discussion of what the API should look like.
Starting point is 00:23:51 So how it should be used from a user perspective. And that actually seems fascinating to me because I think we need to talk about that more of people, how designing APIs and coming to terms with that is almost more important than what the code looks like is because you have to live with the API. You can change the code later if you need to. Yeah, that's a good point. Cause you can refactor internally, but yeah, the API you're stuck with, unless you're like one of the packages I use for security on the website
Starting point is 00:24:22 today, that just completely changed a bunch of the module names and sub modules and move classes around and then my my website uh in dev not in production wouldn't start after i updated it i'm like well i don't don't understand what shouldn't there be at least a deprecation warning for a little bit or something no oh well yeah one of the things i really like about articles like this oh i'm sorry yeah i was gonna say one of the things i really like about articles like this i'm sorry yeah i was gonna say one of the things i really like about articles like this is you know we often talk about like the beginner path like how do i get started with a thing but after we've you know you know brought all these beginners together like how do i take you from beginner plus plus like what is like the
Starting point is 00:24:59 next step look like and you know you always hear folks talk about just you got to read code right? Like go to, go to GitHub and click browse and kind of just dig around projects that you're interested in and things you want to learn about and kind of just try and understand how it works, right? Like if you want to understand how Flask works, if you want to see how folks use different things in FastAPI or Django, or even Tortoise that Michael was showing a little while ago, I mean, just it's open source, right? And that's the beauty about it. You can just go on GitHub and just read the code and then, you know, change it, right? Change it on your machine and see what it does and see, does it get faster?
Starting point is 00:25:32 Is it slower? Is it more or less readable? You know, do you understand it a little better? Did the test make sense? Brian could tell you about like writing good tests for different packages and stuff. But I think we need to do more of this like and we as like an industry because i feel like we're we're like a drowning in how to get started
Starting point is 00:25:51 content now on this level you know what i mean let's let's go like one step above that now and start to talk about like what is the the step two three four look like you know between junior and senior yeah there's definitely that cliff brian you got a learning curve here to back this up? Yeah, no, I just saw this interesting graphic. I think you muted Brian. Oh, yeah, I saw this interesting graphic and I kind of related to it really well in production. I'm not sure about the early parts of the learning curve,
Starting point is 00:26:22 but the end part is welcome to production programming, where there's strange mission critical code left behind by the last developer. And I mean, actually, this is, you know, funny, but also it's true. In, you know, production code in a company, you often have to support code that you don't know what the decisions are. You don't, it's just, it's working, but you're not sure why it's working. And yeah, there's some strange stuff. Yeah.
Starting point is 00:26:50 It can definitely get weird in that stage. But Cecil, I agree that going from like, oh, I learned, learned the language so I can actually do stuff that there's a huge gap right there. Dean out in the live stream says, I wonder if some design decisions that were best in the 90s are less optimal today i feel like in the 90s it was all about object object orienting all the things and then there was like a push like you know maybe that's not the best way to just develop everything like maybe a little bit mixed a little bit of composition and so on uh that's fun and then john, coming from a number of other languages, when I first started using Python, I took a conscious effort
Starting point is 00:27:27 to seek out learning the idiomatic on way of doing things. I think that's really important because it's so easy to just get it to work and then like leave it there. And you're like, no one would ever do this. Well, you wouldn't put your number
Starting point is 00:27:37 in a fake for loop that increments that. And it goes the other way too. So like Cecil mentioned, real developers, And it goes the other way too. So like Cecil mentioned, if you work as a professional developer, you're going to know several languages. But it's not just knowing three languages and knowing how to code C in three different languages. It's about learning the idiomatic way to do Python. It's learning how to do C Sharp the way other C Sharp developers do it. It's not just about trying to translate
Starting point is 00:28:13 your own language into three languages or something. And it's even simple stuff like variable naming and function naming, right? In Java, you start with a lowercase letter and then have camel case. In Python, it's all lowercase. This person clearly is not of this ecosystem. You can just tell straight away just by weird things like naming that are so easy to change. Yeah. I think that's one of the things you see a lot when people do those auto-generated libraries.
Starting point is 00:28:40 So I know some folks, if you're familiar with things like OpenAPI and Autorest and things of that nature, you point a thing at your API definition, it just generates stuff. But what if the casing doesn't match? So if I generate a Java library and a JavaScript library and a Python library, but the casing is going to be different across all those idiomatically. But now these code generation things have to kind of take that into consideration as they're building out these libraries. Your classes like Pydantic that automatically map them over now have to look like Java classes or whatever. I did
Starting point is 00:29:13 see in Pydantic that you can now have an alias. So it's like, this is what it looks like in JavaScript, but it has this other proper name, like this Python name in Python, which I think is kind of cool. All right. Let's talk about something that's really fun and visual. So there's this thing called Gradio, Gradio something. I'm messing up the pronunciation. I'm sure this comes to us from David
Starting point is 00:29:36 Smith. So thanks for sending that over. And this is a really cool way to add simple interactive UIs to your machine learning scripts. So it says generate an easy to use UI for your ML model function or API with only a few lines of code and integrate it directly into your Python notebook or share a link with anyone. So here, like all beautiful user interface things, it actually has not just graphics, but interactive graphics. So you might import Gradio and then write the code implemented, and then just give it the function that it wants to use and say the input is a sketch pad, and the output is a label run. And that's the implementation. So here's a machine
Starting point is 00:30:17 learning model that allows me to draw in ink, and then tell me what letter it is. So if I did like this, it'll tell you oh i think that's a seven that's not a seven let's see what about a one you think that's i think that's a four this model is not very good but that's not the problem that's not the point right that should be a five um i'm gonna draw i'm gonna do a zero there we go yes i nailed it with the zero uh two yeah two notes two i don't know the point is not that the model is accurate, but this is a really cool UI that you can build in a couple of lines of code, right?
Starting point is 00:30:50 I think that's super. Yeah, this is pretty nice. Yeah, let's see what other examples they got in here. Question and answer with a paragraph. So here's the text, the source text is, you know, Victoria has written a constitution enacted in 1975, et cetera, et cetera. And then you could ask the model the question, when did Victoria enact its constitution? Holy moly,
Starting point is 00:31:10 wait for it. 1975. Like that is insane. Right. And you could cool this, uh, uh, you can build this cool UI here, a face segmentation. Um, I'm not going to do my webcam. It's going to break stuff for the live stream. Um, yeah, all sorts of things though like little little sliders and and whatnot um we need social distancing yes here we go so pretty neat way to really simply add uis and integrate them both onto websites and into jupiter notebooks nice i like it i like it yeah i love too that is just running in the browser too so that's i know that's awesome yeah i mean that's proper javascript work to be putting like a little sketch pad and then taking that image and sending it back up dean helping us with the naming um so ml models usually use gradients so called grade in slang
Starting point is 00:31:56 terms i guess grade io yeah that sounds good cool thanks all right so so you're gonna take us out here with the last one you got uh yeah sure let's take a look um all right so my screen should be up now so there's this movie that's coming out later this summer um 2021 called space jam i don't know if you ever heard about space jam um but heard about a long time ago i don't know what's that i only heard of it i haven't seen it yeah i mean you know i i know if anyone anyone that's born after like the year 2000 probably has never heard of Space Jam. But what we actually did, so Microsoft and some folks at Warner Brothers, I believe, partnered together to create like a set of learning modules and stuff like that around
Starting point is 00:32:39 basketball. And it was completely inspired by Space Jam. So what you're looking at here is a learning path. And this learning path, I think, has one, two, three. It has about three different modules in here. And it kind of walks you through exploring basketball data. And you can use that to start predicting the outcomes of games and player performance and all this cool stuff.
Starting point is 00:33:01 But it uses Python, it uses Pandas, uses VS Code. There is some JavaScript in there and there's some like real, you know, there's some NBA data in there. There's some basketball data in there. You kind of use and explore and play around with. So I think this is really cool. Again, going back to the conversation we had before about like, you know, okay, I know some Python, right? Like how do I do some cool stuff with it? Right? Like what's the next step? And I thought this was a great example of us showing, hey, let me let me take something that I actually care about. Maybe some of you care about basketball, maybe some of you don't. But you know, whether it's sports or racing, or, you know, maybe you like to listen to podcasts, how can I take
Starting point is 00:33:36 podcast data and run some machine learning and, you know, different things around it? Like, I think these are all really cool projects for you to think about. But this one specifically is about like using basketball stats, you know, inspired by Space Jam and using Python and pandas and just, you know, just creating some really cool projects out of it. So I thought this was cool. Hopefully folks check it out and let us know what you think. Nice. So this is a free like learning thing that people can go check out, right? Yeah, this is this is 100% free me it's 100 free um free as in like i don't need your you know your address and information and all of that like you could just go on a credit card you cancel any time it's totally free one thing i would tell you if you do
Starting point is 00:34:15 decide to create an account um so i have an account here so you'll notice you'll get points you get xp points so this one is worth 4 000 xp um so if i get that you know hopefully i'll bump up and i'll be at a level you're gonna go to level nine if you get if you finish this one yeah yeah so i want to i want to make sure i get it make some time to go through this this learning um this learning path but if you do want to sign up um you know it's a good way to keep score you get badges and all kinds of stuff um we do have other Python-related courses in here, too. We just released an intro to Django on here. That's in here as well, so if folks are interested in that. Did you guys do something with Dr. Becky around NASA or something?
Starting point is 00:34:56 Yeah, we do have one that's around the moon landing. And then also, if you remember that Netflix movie, I think it's called Over the Moon or something like that. There's also a learn module, I believe, that's also associated with that movie that we partner with Netflix on. So that was also really cool. Yeah. Nice. What I really like about this is when people are trying to get into programming, especially taking that next step of like, okay, I've learned what a loop is. It's so hard to know what can I build? Because you have these, like, well, I'd learned what a loop is. It's so hard to know what can I build
Starting point is 00:35:26 because you have these like, well, I'd love to build a game. Like, well, building a game takes a team of people in a year. Like that's not a good next step. It just like knowing what the next thing to build, that's a little more complicated that you're really actually interested in and you want to build like, this is the type of thing, you know, if you had a, like a coding club at a high school, maybe COVID times is not the best for this but you could say let's build an app that will do like statistics for our basketball team and like all sorts of interesting things like you could build really neat stuff and put it together in ways I think people will care about yeah exactly and and just like I said just in general I think
Starting point is 00:36:01 the best way for you to go from beginner to whatever that next level is, is just find something that you really care about and see if you can attach technology to it. You know, like I care about basketball. I've been watching basketball for years. So when I heard Space Jam and Python, I'm like, oh, that's easy. You know what I mean? Like, yes, like that's something that I care about. That's something I want to do. Like we mentioned before, we have ones on NASA, but maybe you're into some other stuff maybe you're into you know agriculture and flowers and plants maybe you want to do something that categorizes that type of stuff maybe you're into cars maybe you like racing or you know some other activity you know find a way that you can integrate what you're
Starting point is 00:36:38 doing with um you know in your real world life with what you're doing in your computer life right and see if we can put those together. I think there'd be awesome IoT stuff to do with agriculture. Yeah, for sure. I think so too. You know, I've heard about like a lot of different projects that, you know, use IoT, you know, particularly outside of the United States to do things like detecting diseases and, you know, letting them know when's the right time to like manage crops and, you know, letting them know when's the right time to like manage
Starting point is 00:37:05 crops and, you know, getting information from, you know, weather APIs and like using it inside of their IoT devices and stuff like that to help make decisions, which I think is really cool. Yeah. And, you know, when you think about- You could look at the crops and say, how wet is this? You know, could it hold out 12 more hours? Because I see it's going to rain in 12 hours.
Starting point is 00:37:24 So like, let's not waste the water now. Save some money. Yeah, exactly. Little micro-optimizations like that that'll probably save you a lot of money and resources. But it also makes sure that you can control your environment. Yeah. But yeah, I think those are all really cool use cases
Starting point is 00:37:41 that we should definitely encourage more folks to get involved in. Yeah. So I don't know if we should go down it, but Dean is calling Jordan the goat. I don't know what's going on here. I agree with him a hundred percent. I would, I would defend that any day. It goes Jordan, Colby, LeBron. That's how it goes in my head. Awesome. All right. Well, that's all of our main items. Brian, do you have anything extra you want to give a shout out to? No, but I just wanted to say, I thought it was a trick question when you said,
Starting point is 00:38:08 do you know what Space Jam is? I mean, I thought everybody knew what Space Jam was. I had to look it up. I didn't realize it came out in 96. So it's been a while. So yeah, that's what I said. If you're born after 2000, like, you know what Space Jam is. If you've got good parents, you'll know because they would have shown you
Starting point is 00:38:25 I actually made my son watch it like a couple weeks ago yeah did he enjoy it yeah he loved it now you know one day I came home he's just like daddy what are we going to watch tonight I'm like I don't know what do you want to watch let's watch Space Jam I'm like yes I'm a good father
Starting point is 00:38:41 got it my wife and I tried to have our daughters watch all the James Bond 007 stuff. And I said, well, the natural way would be to start at the very first one with Sean Connery and make your way up to Daniel Craig. And today they watched like 10 minutes. Like, this is so fake. I can't watch this. Yeah.
Starting point is 00:38:58 Different generation. Different generation. Yeah. It's different. All right. So let's see. Cecily, got anything you want to give a quick shout out to that didn't land in the main topics um i feel like i should have prepared for this um yeah no i don't think about the twitch are you still doing the twitch streams
Starting point is 00:39:13 brian yeah we're still doing this trip um uh my co-host brian had taken some time off because brian had a baby so congratulations to brian and his family. Congratulations. But he will be back. Well, he is back, but we'll be live streaming again starting next week now that he's back and settled and stuff like that. But yeah, we do a weekly live stream on Twitch. So you can go to twitch.tv, I think it is, twitch.tv slash Microsoft Developer. It's every Wednesday at 1.30 p.m. Eastern Standard Time. And we just, you know, we talk all things Python. We do different projects. Yeah, I believe both of you gentlemen have been on. We've had, you know, Brian come on to talk about testing and solve some problems that I was having. And Michael, you came on too, which was
Starting point is 00:40:00 great. And yeah, we just, you know, we try and take a beginner's perspective. You know what we just, you know, we try and take a beginner's perspective. You know what I mean? You know, my Brian, not Brian on the stream, but like my co-host Brian and myself, we try to take it from the perspective of, okay, well, he knows JavaScript. I know C sharp. Let's come together and like play around with Python and, you know, show all the mistakes and the typos and, you know, the things that happen that we don't always see on video and live streams and show people like, well, you know, anyone could really take the time to learn. You just got to put in the effort.
Starting point is 00:40:31 Yeah. Awesome. Yeah. People should definitely check that out. That's a well done. So before I give my quick one item that I want to share, Dean says PyCon Israel is next week, May 2nd and 3rd. It's free and virtual. So all are welcome. Yeah. Thanks for that real-time update. And then, Brian, people are loving our, what you call it, the absolute privacy updates to the site.
Starting point is 00:40:54 Check this out. 154 people like some random update about removing analytics from the website. I think that's great. Yeah. So now if you go to like pythonbytes.fm in Firefox and you look, there's perfect security shield, perfect privacy shield. And we happen to be live streaming. So did you just remove Google Analytics from it? Is that what you did? We were using GetClicky, which is like a more real time, but it's, I think Google Analytics,
Starting point is 00:41:21 basically the same. The thing I liked about GetClicky is it was a paid service that didn't share your data with advertisers. So it was better, at least in that regard. But all the ad blockers and everything were already degrading the data so badly that it was kind of like, well, it's maybe half of the population. I don't know that we get information about, so let's just take it out.
Starting point is 00:41:39 I wish we would have had this joke last week, maybe two weeks ago, but I've got a good joke for us. You know, there was that giant evergreen shipping container thing that clogged up the canals at the Suez Canal, cost like $400 million an hour, lost commerce with the Middle East and Europe, right? That was bad.
Starting point is 00:42:04 So there's this great joke here about um linux containers and kubernetes so it's got the evergreen ship stuck sideways and like another shipping container clearly stopped like uh this is blocked we can't make it through and then the title is linux containers and kubernetes for beginners like containers yeah that'll fix it. That's hilarious. That's hilarious. By the way, did they ever get that thing out? It got out like a week ago, I think. Yeah. Eventually they had to dig the sand out underneath it until it could float again, basically. Oh my gosh. That's ridiculous. And then Cecil, are you a fan of the Oh Really covers? I am. Yeah.
Starting point is 00:42:42 Yeah. Yeah. So we've got the oh really this is the city of o'reilly kubernetes for beginners what could go wrong dev oops nice i like it dev oops like it but i love the evergreen container ship containers that'll fix it that's serious yeah all right brian is that it yeah that a show put a rap on it nice bow yeah good joke good guest yeah great guest cecil super to catch up with you thank you for being on the show again thanks everybody thank you both for having me come on man and it's always it's always a fun time i'm trying to break the record i want to know who who your most frequent guest is and whatever that is i want to break the record oh i'm going to get one of those great io type things and point it at our site and then i'll ask it yeah no i think actually probably you're you're near the top i have to do some counting we'll
Starting point is 00:43:30 have to see but yeah for sure yeah let me know i gotta make sure i keep i gotta keep standards high that's right brett cannon out there in the live stream if he's still there he's definitely one he's one of the contenders as well so i'll let you know okay yeah Okay. Yeah. Cool. Well, bye everybody. Bye everyone. Take care. Yeah. 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. 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.