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

Transcript #295: Flutter + Python GUI Apps?

Return to episode page view on github
Recorded on Thursday, Aug 4, 2022.

00:00 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds. This is episode 295 Recorded August 4th 2022 and I am Brian Okken. I'm Michael Kennedy. It's good to have you back Good to be back for people out there listening We kind of batch some stuff up so that you have vacation for a couple weeks But now our news items will be more closely related in time to the release of the episode. Oh, we didn't do that >> It was live.

00:28 >> No, it was always live.

00:30 >> I'm glad you got back quickly.

00:34 Speaking of fast, you've got a fast story for us.

00:37 >> Yeah. How about we make things faster?

00:40 I want to talk about Flask and Cort.

00:43 Flask is Flask.

00:45 It's one of the most popular web frameworks out there.

00:47 Cort is the API compatible async version of Flask, originally done by Philip Jones.

00:55 But I think that Philip has joined David Lord in, at least in support of the pallets organization.

01:02 I feel like Flask and Cort are working much closer together these days.

01:05 So I don't know exactly what the relationship is, but Flask and Cort are very closely tied together right now.

01:10 What I want to talk about is routing, or for those UK friends, rooting if you prefer.

01:17 But the idea of taking a URL and figuring out what function to call.

01:21 Right, so what you do is you set up in Flask, you say @app.get,, and you give it URL pattern.

01:29 Sometimes that's just like /about, other times it's like /categories, bracket, category name, or even more general stuff, like where you might say, it's category, maybe a category ID and it has to be an integer, so convert that for me.

01:44 Or I want to just capture arbitrary path, arbitrary URLs, /edit, whatever that happens to be.

01:52 So that's the idea of routing.

01:54 And the whole article here, something, the big news is that Philip Jones has worked on Vexoig, the HTTP router that is the foundation of doing the routing in Flask and Quart.

02:07 And it's something like five times faster than it was before.

02:11 I think five times the number.

02:12 Wow.

02:12 Much faster.

02:13 So for very small little toy apps, if you have a couple of routes, whatever, it's no big deal.

02:18 However, if you've got a production app like say, TalkByThon training where you've got hundreds, at least hundreds of routes, when a URL comes in, you could spend a decent amount of time checking.

02:28 Is it get or is it post?

02:31 Is it this URL and actually this thing here, can we convert it to an integer?

02:35 Because if not, that's a 404, it's a different route and all the stuff that goes on there.

02:39 >> Yeah.

02:40 >> So the way that it worked previously is it just when you would specify these routes like app.get/api, an API slash angle bracket ID, those types of things, it would just come up with a table that just says, "Okay, here's the get verb, here's the path, and here's the function that it goes to." It was using regular expressions.

03:00 So slash API or slash API and then backslash D plus, the regular expression for a number.

03:08 The way it works is it just says, "Okay, we're going to run the verb test, the regex test, all those things, one at a time, top to bottom.

03:17 Well, Brian, I know you studied a lot of computer stuff.

03:21 This is not something that's good that grows with time, right?

03:26 As you add more of these, it's complexity.

03:29 What is it?

03:30 Something like O of N or maybe a little bit O of N squared, maybe?

03:35 I'm not sure.

03:35 Something like that, because you're testing the verbs and you're testing the things, right?

03:39 So as you get these larger and larger, you're like running through them every single request.

03:44 And the world is full of interesting data structures and algorithms that you might consider.

03:49 So the idea was, this is going to get rewritten into something that's not just the sort of brute force test at top to bottom in the order that is defined here. And so I think one thing, it's interesting the news that routing in Flask and Qt is five times faster. That's fantastic.

04:06 but also just thinking about the algorithms.

04:08 I think it's a cool problem solver, problem solving thing to go look at, an example.

04:14 Philip thought about different ways in which you might do this and how it works.

04:20 The first algorithm that he looked at was a radix tree.

04:24 This is an interesting tree structure that gets defined where instead of having a table, you have all the verbs and then under each verb, you've got the path pattern.

04:36 >> Okay.

04:37 >> One of the things that's interesting here is, they have a path type.

04:42 If you were building a CMS or something that would handle arbitrary URLs, you could build a database thing that says, here's a URL and here's the content to show for that URL.

04:54 How do you express all the variations of that in the routing of Flask or other frameworks is you just say it's a path type instead of an integer or something along those lines.

05:05 So there's kind of this wildcard thing that makes it a little bit harder.

05:09 So you've got this get and you've got this post, you've got API, remember we had /API and we had /API/ID.

05:17 So what gets created is there's a get node in the tree, then an API node that if it matches exactly terminates at that column, but if not, then it also has the, well keep going and match the next part of the path as a number.

05:31 And if that matches, then you're going to get this next segment.

05:34 Otherwise, you'll go to the next part of the tree and cruise through it.

05:37 What do you think of that? That looks cool, right?

05:39 >> Yeah. It looks good and also faster because you don't look at everything.

05:45 >> Right. Exactly. You say, is it a get or post?

05:47 Boom, you're down to one segment.

05:49 Then you're like, well, what's this next path?

05:51 You really quickly cruise through the various possibilities.

05:57 This looks really great until you get down to this wild card thing.

06:01 and it turns out with all the variations and whatnot, of like the wildcard matching and the sub wildcard matching, it didn't really work that well.

06:11 But one benefit is the performance is now described as O of N, which is pretty good, better than N squared or something like that.

06:20 >> Yeah. N is the depth now, not the.

06:24 >> Right. That's very important.

06:26 It's the depth rather than just the number, which is even better, right?

06:30 because I think I'm still confused if, if like, if they're all gets, for instance, if you like most of your API is retrieval, are they all going to be falling into that wildcard thing?

06:42 Yeah, I think they would. But then they would just be one. I think it'd be one more step.

06:47 I think that splits pretty quick on the second part. But still, it's not that relevant, because that's that turned out to not work. What works is something I would have never, never thought should apply to this path finding, path determining algorithm.

07:02 Ooh.

07:03 And that's a state machine.

07:05 Awesome.

07:06 Are you a fan of state machines?

07:08 Yes, I am.

07:09 I love them.

07:10 Yeah.

07:11 Yeah.

07:12 State machines are pretty wild.

07:13 You know, I'm in the current editing state.

07:14 Now what are my options?

07:16 Where can I go from here?

07:17 Things like that.

07:18 So you define the same set of routes, but what you get is a state machine that has these transitions.

07:23 For example, state one says, if you go to API, we'll go to state two.

07:27 Or if you do some wildcard/edit, then the answer is you just do the edit, or you just do the true wildcard thing, and then you do some other step there.

07:35 >> Pretty interesting.

07:36 >> Then say for this API where it says go to state two, state two says, well, if there's nothing else, you've already gone through API, then you call the function create API you're looking for.

07:46 Otherwise, if it's a number, go to state three, and state three says, well, if that's it, then you're done.

07:51 Otherwise, you're in this wildcard state and so on.

07:54 The way that you bounce between these states, it's pretty fascinating.

07:58 >> Yeah, and also, how is this faster?

08:02 >> Exactly. Yes, it doesn't.

08:05 Like I said, I would have never thought about it because it also doesn't seem faster.

08:10 However, you get to the benchmarking section and it says, I think by having 20 routes here or something, it came out to be quite a bit faster.

08:21 Let's see.

08:23 Ratio of, this one says 50% better. I said 5 times, maybe it's not that much faster, but somewhere I know there's a 5. There's gotta be, yeah, here we go.

08:31 Factor up to 5 times speed increase. And the more routes you have, the faster, the bigger the increase is. The more complicated and big your application is, the more it's going to benefit from this, right?

08:43 I think it says that if you're looking at just like a toy example, you can run the benchmarks all you want, and it's not going to make any difference, but for realistic ones, it'll be quite a bit faster.

08:53 So pretty cool.

08:55 If you're using Flask record, be sure to use the latest version because the version that's coming out with this, this is going to make it a lot faster for you.

09:03 And just an interesting example of how you might have a non-obvious solution to a problem like a state machine for finding the URL matches.

09:11 - Yeah.

09:12 - Brandon, now the audience says, I agree, I don't see how this is faster.

09:16 I hear you.

09:18 But the cool thing about computers is you push the button and then it does a thing and then you know, right?

09:24 It's not like you got to have a theory and then you debate the theory and it's measurable.

09:29 One of the interesting things around this also is that you can't assume much for Flask or Cort because there are frameworks that other people build up websites with.

09:39 So some people are going to have like big, thick foresty trees that have lots of branching and everything for their, for their routes.

09:48 And some people are going to have like, oh, let's just throw half the stuff in one, in one directory or one bucket or something like that.

09:54 Right. That's true. A lot of people have different variations of how they construct the URLs that map to your site.

10:01 And that also affects it. That's true.

10:03 >> That's true.

10:04 >> You have to have both be faster or not.

10:09 You just have to not be slower in really any case.

10:13 Interesting.

10:14 >> Yeah. Also looking at the state machine, there's only four states.

10:17 Most things terminate in one or two steps.

10:22 Instead of testing four, five, six different regular expressions, doing one or two.

10:27 >> Yeah.

10:27 >> But yeah, it is interesting.

10:28 What do you got next for us?

10:30 >> Well, speaking of court, We've got court. Oh, or corto. And actually, it's funny, I have no idea if this is built on court or not, probably not. But I don't know. So corto. This was Oh, somebody said, suggested it Paul McKenzie. This is a, this is a thing to build documents and stuff. But it's, it's open source. And it's, it's, it's, they say open source scientific and technical publishing system built on Pandoc. So we love Pandoc, at least I do. It converts Markdown to really anything else, or REST to other stuff. Like a whole bunch of stuff. You can convert things to like PDFs or even ebooks and HTML documents, all sorts of things. So this is, and then Jupyter, of course, Jupyter's great for a lot of scientific Python research and data science, and even just learning in Python and playing and stuff.

11:27 And I've kind of liked to see lately some people doing presentations even with just right within Jupyter Notebooks, just kind of fun.

11:38 And I know people are teaching that way with tutorials.

11:40 But anyway, so Cordo is a system where you can do, you can have documents be either Markdown documents or Jupyter Notebooks and have a combination of these things around and then build up stuff.

11:52 So you can, so you know, you've got like a Jupyter Notebook in a demo and some markdown and stuff.

11:59 Then you can convert the whole thing to a website or a journal entry, a publication ready for a journal or a website or an e-book or really anything.

12:11 This is pretty exciting.

12:12 >> I think it's very neat.

12:15 The idea you can take a notebook, put a little extra metadata into it, and then publish it to all these different sources.

12:22 Have you seen how much you can do?

12:24 This is based on Pandoc.

12:25 Have you seen how much you can do with Pandoc?

12:27 Have you seen the conversion?

12:28 Like, here, I'll pull up their homepage here.

12:31 You just go to

12:33 See on the right, that thing that looks like gray shading?

12:37 - Yeah.

12:38 - Those are the different formats that it can convert from or to.

12:41 - Yeah, it's incredible.

12:42 - It's just like, unbelievable, yeah, yeah.

12:44 So when you say, okay, well, if I could take my notebook and then power it through Pandoc to do these things, like, the output possibilities are insane.

12:53 >> Yeah. One of the things that was unexpected for me is the presentation.

13:00 So you can convert one of these to-

13:03 >> To PowerPoint?

13:05 >> Yeah, even to PowerPoint.

13:07 I was excited about Reveal.js.

13:10 I like Reveal.

13:11 But in Beamer, I don't know what Beamer is.

13:14 >> I've never heard of Beamer either.

13:16 It's going to be our new favorite way to present.

13:18 You can create Beamer LaTeX.

13:21 >> I see. So is Beamer maybe is a little more scientific, mathematical where you have to have, here's the integral of this or where you've got really specific things possibly, I don't know, specific formulas.

13:33 >> Then within each of these formats, there's things like, so I use Reveal.js for instance, but the documentation is great.

13:43 It talks about using this to create code blocks and line highlighting.

13:48 Check this out, you've got line highlighting that goes incremental.

13:54 So you could have stages, instead of creating three slides, for instance, that have just slightly different highlighted text, you can say what order you want things highlighted in as you step through them.

14:07 So I'm going to try this for presentation.

14:10 >> I might try this as well.

14:11 This is pretty neat actually.

14:13 >> I was excited also about the e-books feature.

14:16 You can even publish EPUB.

14:19 I was talking to Matt Harrison about this, and Matt pointed out that he'd seen this, but he was, if you really care about indexing or the front matter or the back matter, this doesn't quite get there for generating that stuff.

14:34 But there's cross-references and all sorts of things that it does do.

14:38 So if you're just starting out a publication, this would be kind of fun.

14:43 So I'm excited about this.

14:44 The reason, one of the reasons why I brought up EPUB is I read all my, I read all my eBooks on a Kindle.

14:53 And whenever I used to see this, I was like, but do Mobi also, 'cause I wanna be able to read it on my Kindle.

14:58 - Yes, exactly.

14:59 - But I don't have the link here, but Kindle, Amazon is doing a conversion this year.

15:05 So right now the mail to, the last time I sent a Mobi document to my Kindle through the email feature, it emailed me back and said, "We did this, but EPUB is preferred now." >> Oh, interesting.

15:19 >> They're moving away from the Mobi format and back into EPUB.

15:25 That's really cool.

15:26 >> Cool. Yeah, I use the Send to Kendall app.

15:29 It's some weird old archaic app format.

15:32 [LAUGHTER]

15:33 >> Really?

15:34 >> Yeah. It's some weird install an app off the web.

15:40 That's not a progressive web app.

15:41 I can't remember what it is. It's something.

15:42 >> Okay.

15:43 >> I think from Adobe, it's some bizarre format, but yeah, that's what I use.

15:47 >> You get this e-mail address that you can send stuff to and it just goes right to your Kindle.

15:53 >> Yeah, nice.

15:53 >> So that's what I use usually.

15:55 >> Anyway, I would probably use that if I didn't have so many Kindles over the years, and I don't know which is the real e-mail for it.

16:03 Because I have like five Kindles over and I lost some of them.

16:06 >> You can unregister them, man.

16:08 >> Oh, come on. Yes, I should do that.

16:11 So for the website stuff, it's kind of fun too.

16:14 So this will generate websites for you.

16:16 And then it has publishing input, publishing in it too.

16:21 So you can hook this up to a GitHub action and just say Quattro publish and be using this to publish stuff too.

16:29 So this is really kind of cool, the whole infrastructure around documentation and publishing around scientific computing.

16:39 So I'm pretty excited about this.

16:40 - Yeah, I love it, it's great.

16:42 Now, before we move on, Brian.

16:45 - Yes, another thing I'm excited about is Microsoft for Startups.

16:51 It's the Microsoft for Startups Founders Hub.

16:55 So this episode of Python Bytes is brought to you by Microsoft for Startups.

16:59 Starting a business is hard, but by some estimates, over 90% of startups will go out of business in the first year, ouch.

17:05 With this in mind, Microsoft for Startups set out to understand what startups need to be successful and create a digital platform to help overcome those challenges.

17:14 Microsoft for Startups Founders Hub.

17:17 It provides all founders at any stage with free resources to help solve startup challenges.

17:23 The platform provides technology benefits, access to expert guidance and skilled resources, mentorship and networking connections and so much more.

17:31 Unlike others in the industry, Microsoft for Startups Founders Hub doesn't require startups to be investor backed or third-party validated to participate.

17:41 Founders Hub is truly open to all.

17:43 So what do you get?

17:44 Speed up development with free access to GitHub and Microsoft Cloud with the ability to unlock credits over time.

17:50 To help your startup innovate, Founders Hub is partnering with innovative companies like OpenAI, a global leader in AI research and development to provide exclusive benefits and discounts.

18:00 Through Microsoft for Startups Founders Hub, becoming a founder is no longer about who you know.

18:05 you'll have access to mentors, their mentorship network, giving you access to a pool of hundreds of mentors across a range of disciplines, across areas like validation, fundraising, management and coaching, sales and marketing, as well as specific technical stress points.

18:20 You'll be able to book a one-on-one meeting with mentors, many of whom are former founders themselves.

18:26 Make your idea a reality today with the critical support you'll get from Microsoft for Startups Founders Hub.

18:33 To join the program, visit

18:38 The link is in your show notes.

18:40 - Awesome, yeah, thanks Microsoft for supporting the show.

18:42 They're big backers of Python Bytes and definitely help amplify what we're doing here.

18:47 I think the most awesome thing is the mentors and the advice and the support you get.

18:52 - Yeah, well, one of the things I think is awesome is when I read about this, I think about like the startup access that people get if they're in like Silicon Valley or--

19:05 - Like Y Combinator or something like that.

19:06 - Yeah, something like that.

19:07 But this is, but that's, you only get a handful of those a year and this is open to way more people.

19:13 So that's cool.

19:14 - Awesome, yeah.

19:15 Very cool.

19:15 All right, can I take you on a diversion to show you something pretty cool?

19:19 - Yeah.

19:20 - All right, so Dart is a programming language that we don't usually talk about on Python Bytes, right?

19:27 And Dart is a language that came out from Google And I felt like it was trying to compete with JavaScript to a large degree and didn't really gain a lot of traction until Flutter came along.

19:41 And Flutter is a really cool way to design mobile and desktop native applications using Dart.

19:49 Think of it as an alternative to Cordova, PhoneGap, Xamarin, Ionic, all these different sort of generic ways to build apps that run on different platforms.

20:02 So with Flutter, I can build an app that runs on iOS and Android, but I can also compile it as a target to macOS, Linux, and Windows.

20:10 And I can even compile it to a target for the web where it'll run as a progressive web app, okay?

20:15 And you get some really cool apps.

20:16 Like by far the most well known one is the BMW car.

20:21 You have a BMW, this is like the app that is your car.

20:24 But there's other ones as well.

20:26 It's used a lot within Google, obviously, right?

20:28 - Now you may be wondering-- - I would be ticked if I bought a car and all I got was an app.

20:31 - I know, I would be too.

20:33 By the way, sidebar, BMW's doing all sorts of weird stuff, like charging you subscriptions to use your seat heaters.

20:38 $18 a month subscription to turn on the seat heater that's already in your car.

20:42 So the least thing I'd be upset about is the app.

20:46 - Okay. - But that's something else.

20:49 Now why in the world am I talking about Flutter and Dart?

20:52 I'm actually looking into using Flutter and Dart to rebuild the Talk Python Training apps so that we can have macOS, Windows, and Linux in addition to the iOS and Android version and give it like a refresh.

21:05 And it's a really cool technology that I'm pretty excited about.

21:09 So let me introduce you to something called Flet.

21:13 Have you heard of Flet?

21:14 - Well, just because Brandon just mentioned it.

21:16 (laughing)

21:18 Tell me about Flet.

21:20 - Yes, yes, yes.

21:22 Very timely, Brandon.

21:24 So Flut was sent over to us from Mikhail Honkala.

21:29 And Flut is the fastest way to build Flutter apps, but instead of using the Dart programming language, use Python.

21:36 - Oh, perfect.

21:37 - So let me see if I can, I'll go to the get started, I'll pull up a little example here.

21:42 So there's an app here, check it out, it's a calculator.

21:45 And look at it, it's got a nice little animated GIF showing how it works.

21:49 And this looks like a proper calculator app you would see on a mobile phone or something, right?

21:54 Yeah, it looks like my calculator.

21:55 Yeah, exactly.

21:56 And you could even go see a interactive version that is running in your browser because one of the six or seven compile targets is your browser.

22:05 And I don't know if you noticed, but how quick did that load way faster than PyScript or any of these other things?

22:11 It was like nearly instant.

22:12 So if you go through and you look at how you build it, you just create a main method in Python and it's provided a page and you say flat dot app and you just give it the function to call and here you say, I'm just going to add some text called Hello World.

22:26 You get your Hello World here, but you don't want that, you want some controls.

22:30 I'm going to add a bunch of elevated buttons with the buttons that are on the calculator, like 1, 2, 3, star, plus, minus, and so on.

22:38 You end up with this column of that.

22:40 That's interesting, but you want these in rows and columns.

22:44 You would say, I'm creating a row, which has some controls for elevated buttons.

22:49 another row, right? So these are the rows of the calculators. And look at that already how cool it is to define that UI with just just that in Python.

22:57 Yeah, right. It's pretty neat. And because it's Flutter, all of these things have native representations on their platforms, right? In macOS, it looks like a macOS button and Windows looks like a Windows button and so on. You got to put styles to make it look like, you know, the calculator app type of thing. So yeah, that's pretty much it. You just go and you put all these controls together like this and you say go and then somewhere in here there's a place where it talks about handling the input. But yeah, so here you just say I have created a class and then on click it self dot button clicked or whatever it is, whatever you're interested in. And what it's going to pass over is the actual button, the elevated button that was clicked, the event source or whatever you call it.

23:45 >> Right.

23:45 >> So you just say, "I'm hooking into these different button click events like you would with any UI reactive framework and now you have a calculator, or you've got what other app you want to build." Isn't that cool?

23:58 >> It's very neat. So you can build both.

24:02 I think some people would use this for iOS or Android, a mobile device, but you said there's other things too, like you can test it out.

24:10 Would you realistically use this to develop a web app?

24:14 >> I think developing a web app seems like it would be totally reasonable.

24:18 If one of the things if you look here, if you go to the roadmap, the mobile story is not yet complete actually.

24:25 >> Okay.

24:26 >> So right now I would think of it as more of a desktop type of thing.

24:30 But as you saw with that example, there's also a desktop and progressive web app story.

24:36 The mobile story is not yet finished, but that's what's on the roadmap and I would love to see it come along and make good progress.

24:44 There's also the possibility of other languages.

24:47 That's not super interesting to me, but because I want to write Python.

24:52 Anyway, but you have like Go and C# and stuff as possible other programming languages.

24:58 >> Yeah.

24:58 >> But things like having a built-in database with a simple ORM, it's way more powerful than it sounds.

25:05 Because if you're in the web, well, how do you do database stuff?

25:09 The web has local storage and it has like a SQL, a wimpy SQL thing that's embedded in offline storage for your app.

25:18 If you're on iOS, you've got SQLite built in and stuff, but figuring out all those variations is a pain.

25:24 But if you can just say, create a database and do queries against it with an ORM, all of a sudden, that gives you a super cool offline data access story.

25:32 >> Yeah.

25:33 and so on, so anyway, yeah, and I think there's a lot of neat things that are coming here.

25:39 This is created by, let me see if I got the name, by Fedora, Fitzner.

25:45 I'm actually having Fedora on Hock Python next week to talk about this, so we're gonna be diving even more into it.

25:51 - Okay, cool, nice.

25:53 - I don't know how ready this is for producing actual finished applications.

25:58 Flutter is absolutely ready to go, right?

26:00 It's been around for many years and there's lots of things being put out in production for it.

26:04 Flutter on top of Flutter?

26:06 Don't totally know.

26:07 I'll ask for it later, next week, and we'll know a little bit more.

26:11 But when I look at this, this is really exciting, because it looks like it builds applications that I would really want to use, using modern paradigms and all sorts of cool stuff.

26:21 And you should be able to integrate with all the Flutter things, which is great.


26:25 MARK MANDEL: Yeah.

26:25 Anyway, very cool.

26:27 Thank you, Mikhail, for sending that over.

26:29 So that's a UI thing.

26:32 I'd like to switch gears to the command line.

26:35 So I--

26:36 - To the TUI.

26:37 - To the, to the CLE?

26:39 - The TUI, the text user interface.

26:41 - Oh yeah, text user interface.

26:43 Yeah, that's, anyway, so like with rich and textual and things like that.

26:47 So I was really excited about this article actually, and now I'm a little confused.

26:51 So I'm glad I'm gonna talk it through and you can let, I'd like to hear what you think.

26:56 So I ran across this article, it's called "Building an Authenticated Python CLI" and it's from Notia, Notia?

27:07, N-O-T-I-A.

27:09 Anyway, it's a blog post about building this.

27:12 So here's the idea.

27:13 So if you've got a, for this application you need Twitter authentication.

27:19 So if they're developing a command line application that has to use the Twitter API.

27:27 To get that, we've got some secrets.

27:29 You've got a client ID and a secret that you've set up and you need to store the Twitter token somewhere.

27:36 - You've gotta do that OAuth exchange where you say, "We're gonna connect to Twitter." And Twitter says, "This app is gonna interact "with your account this way," and whatnot, right?

27:45 - Right, so I wanna be able to just, but I'd like to be able to have the application keep that around and not have to do that, not really build it into the app, like I don't want to compile it into the app or copy that token there.

27:59 I want to be able to put that somewhere else.

28:01 So the idea around this article is to take that, use the Twitter API.

28:06 They talk about using click and rich a little bit, but for the command line stuff and click is cool.

28:14 We, and we both love rich.

28:16 And anyway, so the idea is to use, once you have, so use the OAuth and you come back and you've got a bear, what they call it?

28:25 >> A bearer token.

28:27 >> A bearer token.

28:28 Then saving that in a file called a net RC file.

28:32 Instead of telling somebody to just go put it there, they're reading, asking the user for the client ID and the secret from the Twitter API website stuff.

28:44 Copy it and paste it here.

28:46 Then they're storing the bearer token in that in the netRC file.

28:54 Then the next time the application runs, it just reads that and you don't have to do it every time.

29:00 Then that stuff isn't stored with the client code, but it's stored within the user netRC file or something.

29:08 At first, I thought this was something that you could use for, I don't know whether or not this is a good idea for that even, whether you want to store your barrier stuff.

29:21 But you probably don't want to store, you don't want to ask the user for username and password and store that there, because it's just a text file, I think.

29:31 But maybe there's some other way around.

29:34 I was hoping that-

29:35 >> I'd rather lose an OAuth token than I would my actual username and password, because at least you can revoke the tokens or expire them and stuff.

29:43 >> Okay. For token stuff, for saving tokens, is this a reasonable thing to do to keep that in the user's directory or something?

29:50 >> Seems like it's all right.

29:52 I'm a little suspicious of storing straight plaintext, even if it is just an OAuth token.

29:59 >> Yeah. Okay.

30:01 >> I don't know because I haven't read the article all the way through, but I might encrypt the token and then store it.

30:07 >> Yeah.

30:08 >> Yeah. Actually, so I wanted to start this conversation and then ask people because either for Tok--

30:15 I know there's other password ways to store them locally safely, but is it something that you do that with--

30:23 Anyway, I'd love to hear people's thoughts on this, on what's the best way to store people's secret information so they don't have to enter it every time.

30:36 >> Yeah.

30:37 >> Storing in their user directory might not be terrible, but maybe there's a better way.

30:42 It's probably operating system specific too, but I don't know.

30:46 >> Right. Well, your user profile is protected in general from other users.

30:52 >> Right.

30:53 >> But is it protected if you run an app that decides it's just going to go cruising through your user profile?

30:59 Something that you ran and you should have trusted it, but you did.

31:02 I mean, SSH keys, private keys are there in the .ssh folder.

31:07 >> Yeah, that's true.

31:09 >> That's probably worse than losing an OAuth token as well.

31:12 So if you can guess, I'm thinking of, I'm in the design process for a command line application that has to store user credentials.

31:19 So that's where I was running across stuff like this.

31:22 I mean, isn't that one of the benefits of doing this podcast?

31:25 It's a byproduct of our natural just working on new projects.

31:31 Like Flutter for me on the previous one, right?

31:33 Yeah.

31:33 Yeah, this is interesting and I see where it goes.

31:35 Yeah.

31:36 But yeah, I would probably at least encrypt the token.

31:38 I don't know.

31:39 Okay, thanks.

31:40 Maybe it doesn't matter.

31:41 Yeah.

31:41 - Well, they're done with our normal items.

31:44 So the extra stuff that I had, I was gonna let you go first, but I'm super excited.

31:52 I'm getting a whole bunch done on the pytest course.

31:54 - Really quick before you go on, just Sam Morley out there says, "That's why you should encrypt your secret keys." And system toolchain is probably the correct, in quotes, answer.

32:03 - Okay, system toolchain.

32:05 Okay, I don't even know what that means, but I'll look it up.

32:07 - Yes, this is something that go, - Kagi or DuckDuckGo or maybe Google.

32:11 - Okay.

32:12 - I'm excited to hear about this pytest course 'cause people have been asking and progress is being significantly made, right?

32:18 Awesome.

32:19 - Yeah, it's going great.

32:20 So I've got, it's really seven chapters, broken up into seven sections or chapters, but it's a video course.

32:29 But I'm really excited about it 'cause the pytest book has received a lot of people of it, which is great, I love that.

32:37 I got a lot of great feedback.

32:38 But it's detailed, right?

32:41 So we jump into a whole bunch of the details.

32:44 And with a book, you can kind of get to some section that you're like, yeah, I don't need that right now.

32:48 And you can skip over it.

32:49 And yes, you can do that with a course, but it's a little harder.

32:52 So the goal for this is really for people new to pytest or that are just using a little piece of it and unfamiliar with some of the powers is to introduce people to like the full power of pytest, but quickly and not overwhelm them.

33:08 So I think I've done a good job, but we'll see.

33:10 We'll get it edited and get it available to people as soon as we can.

33:14 - Yeah, I'm excited.

33:15 - Yeah.

33:16 - Yeah, I'm excited to check it out.

33:17 It's gonna be awesome.

33:18 - All right, how about you?

33:19 Do you have anything extra?

33:20 - Good lead in.

33:21 So brand new course over at Talk Python Training.

33:25 Django getting started, which is awesome.

33:27 This is put together by Chris Trudeau.

33:29 And this is a six hour course on Django.

33:33 And right now people, hurry, hurry, there's an early bird discount to save 10% that you can get as well.

33:39 So that just came out Wednesday.

33:41 Wednesday is yesterday.

33:42 So it came out yesterday, I think.

33:44 That or the day before, very recently.

33:45 Anyway, if you've been wanting to do, getting started in Django, if you wanna get into Django, this gives our Django course is really good.

33:52 If you've been dabbling, and you're like, ah, I really need to see how the pieces fit together better, also check it out.

33:57 It's definitely good stuff.

33:58 Django is one of the top two web frameworks these days still in Python.

34:02 - Yeah.

34:03 Do you know how many courses you've got on the platform now?

34:07 43 courses and about, that platform tells me, and 233 hours of content.

34:14 So there's more than that in there, but a couple are not published yet.

34:17 There's some exciting ones coming.

34:19 - Cool, nice, sweet.

34:20 - Yeah, yeah, yeah.

34:21 All right, well those are all the extras I have for now.

34:23 I do have a joke for you though.

34:24 - Oh, good.

34:25 - Are you a fan of "The Lion King"?

34:27 You ever watch that show, "The Lion King"?

34:29 The cartoon, Disney, it was a Disney, I don't know.

34:32 - I saw it, I don't know if I'd call me a fan, but sure.

34:34 - No, oh, did you enjoy watching it, I guess, at all?

34:37 >> Yeah.

34:38 >> Yeah. I watched it with my kids and we enjoyed it as well.

34:42 I don't even remember the name of the father.

34:46 Remember the name of the father?

34:47 The actual Lion King?

34:49 >> No.

34:50 >> Whatever. Yeah, exactly. I don't either.

34:52 But the little kid that was supposed to be the kid lion, who was supposed to be being groomed to be the king, is talking to his father and they're looking over the vast kingdom.

35:02 This is Luxembourg.

35:04 Every language that light touches has a garbage collector and symbol.

35:09 But what's that shadowy place over there?

35:12 That's a C++, you must never go there.

35:15 >> Yes.

35:17 >> Sorry, C++, but that was fun.

35:19 >> Mufasa.

35:20 >> Mufasa, yes. Thank you.

35:22 Yes, you got it. Mufasa says, that's a C++, you must never go there.

35:26 >> No, but you should.

35:28 >> Don't take it too seriously, the joke, but it was fun.

35:33 >> As a garbage collector.

35:35 >> Yeah, I know.

35:36 >> What's that shadowy place over there?

35:39 You must never go there.

35:41 >> What about Rust?

35:43 >> What about Rust?

35:44 >> Nice.

35:45 >> I don't even know enough about Rust to make this part of the joke.

35:49 I'm busy learning Dart and Flutter.

35:52 Maybe I don't have to learn Dart though, because I can do it in Python.

35:55 I could just learn Flutter. We'll see.

35:56 >> That would be like, that is Rust.

35:59 You can go there, but come back quickly.

36:01 >> Exactly. Just short visits.

36:04 >> Short visits.

36:05 >> Yeah.

36:06 >> It's a fun show too.

36:07 >> Well, thanks for having this great episode.

36:09 >> Yeah. It's great to be back with you.

36:11 >> Yeah. I guess we'll talk next week.

36:14 >> Yeah. You bet. See you.

Back to show page