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

Transcript #139: f"Yes!" for the f-strings

Return to episode page view on github
Recorded on Thursday, Jul 11, 2019.

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:05 This is episode 139, recorded July 11, 2019.

00:10 I'm Michael Kennedy.

00:11 And I'm Brian Okken.

00:11 And I want to welcome Enis Montani to the show.

00:15 Enis, it's great to have you here.

00:16 Special guest, going to help us cover the news of the week.

00:18 Thanks for being here.

00:19 Yeah, thanks for having me.

00:20 I'm really excited.

00:20 It's going to be really fun to have you participate in this.

00:23 Also, thank you to DigitalOcean for sponsoring this episode.

00:25 Check them out at

00:28 More on that later.

00:29 Brian, we've talked a lot about like, how do you install Python?

00:32 How do you manage Python?

00:34 How do you upgrade your stuff?

00:35 There's just so many ways.

00:37 And then we've got things like pipenv, flit, poetry.

00:40 It goes on and on, and it still goes on, right?

00:43 This was a contribution from Niels de Bruin sent us this.

00:46 There was an article called "Simplify your Python Developer Environment," and it talked about using pyenv, pipx, and pipenv together.

00:56 And my first reaction was like we've already covered all of these However, I have tried pip X actually I did the joke the pie jokes. I did that with pip X and I've tried pip end once before it doesn't really do anything for me that I really need and the pie Env I've tried it and it didn't work for me. So Actually all these things I kind of wanted to give them another shot anyway So I went ahead and read this article, and it actually is pretty nice.

01:26 It's a nice pros and cons of all the tools and how to set them up.

01:30 And I think for somebody that wants to try these out again, this is a good article to read to try to get back into it.

01:37 So if people don't remember, pyenv is used to install and manage multiple Python versions and flavors on a computer.

01:46 And then PipX is something that allows you to create, take a Python application and have it bundled with its own virtual environment and use it globally on your system without having to activate the environment.

01:58 And then Pipenv is for when you're working on project and application, it's a way to manage virtual environments and dependencies on a per project basis.

02:07 - These are really interesting because I feel like often they kind of blend, like in a blur together, right?

02:14 You're like, well, I know there's all these ENV things I could use and whatnot.

02:18 and it's like, "When should I use what?

02:20 And what one is relevant for the situation?" What do you think, Enis?

02:22 It actually took me a second to remember the one that I've used.

02:26 So I'm totally in the market for stuff like that.

02:27 But actually, I hadn't heard of pipx at all.

02:30 But I think, yeah, pyenv I definitely use.

02:32 And I think it's quite important, at least for the work I'm doing, because I need to run stuff in all kinds of Pythons.

02:38 And I mean, as a library developer, we need to build stuff for like Python 2.

02:43 We're supporting Python 2.7 and 3.5.

02:45 Just so folks know, you're deeply involved with spaCy and some tools built on top of that, the natural language processing, which will come evident as we go through some of your topics and more, but maybe not everyone knows your background.

02:56 But I feel like pyenv is most relevant for people building libraries, and pipenv is really relevant for people building applications.

03:07 I don't know, what do you think, Brian?

03:08 - Both of them are important for people like us that have to do both.

03:12 I have a question for Inez.

03:14 the pyenv, so that one of my concerns was, can I use it to install, to have multiple pythons and still be able to run them all from one project, like with the talks build to be able to access all of them?

03:28 So I haven't tried it all, like within the exact same project. I think you might need different virtual environments for that. At least that's how I use it. So I use VM to create my virtual environments and then they are created with whichever python version I've configured locally. So I do like I am local to seven and then the virtual environment will have two seven in it Okay, well, i'll give it a shot. Yeah. Yeah, really nice. I'm a big fan of pipx. I think pipx is super cool So pipx is great If you have a thing that you just want as a utility on the command line in your terminal That happens to be python based. So instead of brew install something or npm install something pipx does that?

04:07 So for example, I have like cookie cutter. I have the http high library of glances, I pie jokes, of course, because we run this podcast, and some other stuff that I'll even talk about later, like PT Python.

04:19 Is that a bit like PX files? Or is that something else?

04:22 It's a little, a little bit what it does is you say I want to have, let's say I want the utility PT Python, which is like an EMAX enabled rebel, basically. Okay, so I want to have that and I want to be able to just type it. It's not tied to any project, I just want to have it as a command on my computer that I can use. So what you can do is you can pipx install ptPython, and then it just automatically puts it in a location, modifies your path, so that it has its own virtual environment.

04:48 It upgrades itself and its dependency separately, but anytime I want, I can just type ptPython and go crazy, or Glances, or PyJove, or whatever.

04:55 Okay, I think I get it. Okay, that actually sounds quite cool, yeah.

04:58 It's really nice. You can just say, "What are the updates for my Python libraries that I use as applications or little utilities?" It's pretty cool. I like that one as well.

05:05 Yeah, I wonder if we can ship our annotation tool, Prodigy, like that, because it's very, very command line heavy. And, you know, it's usually kind of a separate thing.

05:13 All it does is build upon pip. So if you could pip install the thing, and it has an entry point, then you can pip x install it as well. Okay, yeah, cool. Yeah, pretty cool. All right, Brian, are you switching to this? Are you going to use pyenv, pipx and pipenv? Is this your new plan? I definitely want to try pyenv because I want to try new Python versions. And my old process was to just download the regular install and install it. And then my path is all weird.

05:42 And yeah, it's a mess.

05:43 Classic.

05:44 Cool. Yeah, this is nice. Definitely for people looking for a different workflow, it's something they can check out for sure. All right, Ines, what's this next one that you got for us?

05:51 This week was actually, or like the past few weeks were actually like super exciting also in my field. So there was a new release of a fast AI course for natural language processing.

06:01 So is a very popular free online course for deep learning by Rachel Thomas and Jeremy Howard.

06:07 And it also comes with a Python library, comes with lots of notebooks, really active communities.

06:12 So if you want to get into like the modern machine learning stuff, that's like probably the go-to course that I would also recommend to you. And they've also produced some very influential research developed alongside the library and the course. So for example, ULM Fit, which was a very popular algorithm for text classification. And yeah, the new thing is they've just released a course on natural language processing. And it's a very practical introduction.

06:36 And what I thought was really, really interesting and really cool about it is that it, of course, covers like the modern neural network approaches and all the like very hip stuff. But it also focuses on traditional techniques. So just the whole background of like, okay, what did people do before deep learning topic modeling, linear models, just really all the basics. And even like rule-based approaches, like regular expressions. Some people might look at this and be like, "What, RegEx? I did that 20 years ago." But in fact, in real life and in real-life practical applications, that's super important. And you can do a lot with that that really gets the job done.

07:12 So I thought that was really cool. And of course, another thing, the course has a really strong focus on ethics as well. So there are videos on bias and disinformation, and basically just a topic of like, okay, think about the impact that the work you'll be doing has. And I thought that was incredibly refreshing. And of course, disclaimer, like I haven't actually watched all the videos yet. I don't even think that's like physically possible to do all of that since it was released.

07:36 It's too new and it's too long. Yeah.

07:38 Yeah, it's like is a lot of material. But yeah, I really like the work they're doing.

07:42 And it's like, yeah, it's a very, very significant release. And it's off weight.

07:45 Yeah, it's super cool. Yeah, it looks like it's free. Like I was able to go pull up the videos without even having an account there. It just sort of takes you through it more like an online video book you just make your way through, right? Yeah, and there are lots of like notebooks, so you can open the same notebooks, you can play through the examples, and of course also use their library to, you know, really work through the things efficiently. Sure, that's super cool.

08:05 Does it cover any of the libraries that you all work on, like spaCy or anything?

08:09 spaCy is a much more like high-level toolkit and framework, so it's like, you know, this is really the basics of the technology. So while the FastAR library, I think it does use spaCy for tokenization, but spaCy is really, you know, once you're building applications and you have some problems and you want to construct your pipelines and really ship something into production, that's when you would be using spaCy. But actually, in fact, spaCy is not really the best solution if you really want to learn the underlying algorithms and implementations, because we're actually super opinionated. You get one implementation and, you know, you kind of take that or you plug in your own.

08:41 I see. This is like learning the algorithms and the foundations that maybe spaCy uses, so you understand it better.

08:46 Yeah, exactly. And also, you know, giving you some, yeah, the background and yeah, even, even the rule-based ideas, which, yeah, I still think it's so great. I scroll through it. I'm like, great, regular expressions. That's like really what people should think about.

08:59 Yeah, I mean, that's a start, right? Like sometimes you just want to pull data out of text and there you go.

09:03 Yeah. And especially then some people really, you know, then they start throwing like a neural network model at it when actually best solution would have been to just write one regular expression. Like, I don't know, you work at a company, you have a statistical model that recognizes organization names, and then your manager comes to you and is like, "Well, it's all great, but it often gets our own company name wrong. Can you fix that? That's really embarrassing." And you can spend hours trying to tune your model and update it and fine-tune it with more examples, or you can just add one regular expression or one rule on top that says, "Okay, whenever I come across this string, don't get it wrong.

09:38 And that will likely take you like five minutes, and it's much more effective in the real world.

09:42 So this is the practical, applied natural language processing, right?

09:46 Yeah.

09:46 Speaking of language, this next item that I want to talk about, it just scares me.

09:51 So let me tell you quick about it.

09:52 I'll get your two opinions.

09:54 The idea is that we can clone the human voice by giving it a sample using some sort of neural network type thing.

10:02 I'm not sure exactly.

10:03 So this was sent in by Brendan.

10:05 Thank you for sending that over.

10:06 And you know, in just a couple of minutes, you can load up somebody's voice, use some Python, a pre-trained machine learning model, and then type in text, and it will speak whatever that text is in the voice of that person.

10:21 And this is just, I don't know, I feel like public discourse is in serious jeopardy here.

10:26 What do you all think?

10:27 - This is pretty interesting.

10:28 And I was a little frightened actually watching this video how easy it was to copy somebody's voice. I mean, I don't know the code behind it's probably not easy, but it's a little creepy. My first thought was I could use it for if I have solo episodes, I could be my own co-host. But that'd be cool.

10:46 That'd be pretty funny.

10:47 Yeah. I mean, I think I would say, I think it's still quite compute intensive, like to do that, right? I think you still, you know, if you really want to have good results and really want to do it right. But it's true that this, you know, this really, this is really good example of, wow, that's possible and that's the type of stuff that's been possible for quite a while, especially across video, image, and also voice, audio. Right. I mean, we've heard of the deepfake stuff for videos and whatnot, and that's kind of scary. But this is, it's almost like, this can be worse, right? I can imagine somebody just putting a little static, a little muffling filter on it and saying, "Oh, here's a hot mic take behind the scenes. Somebody said something they weren't supposed to during a presidential debate or some kind of public figure they're trying to discredit and just make them say stuff. Now, I don't know what you all think. To me, it still sounds a little bit off. Like, it doesn't sound exactly like the person, but, you know, it's pretty close. But I think you could still use it. Yeah. And also, I mean, I do think this type of technology will definitely lead to a situation where we will all just take things we hear in like recordings or videos much less seriously. Like, you know, we, I do think it will develop into a culture where we don't necessarily trust an audio recording because, you know, it could have been produced by something like this. But I do think just for very everyday life scam, like I think it's very timely because, yeah, there were all these news articles about all these like financial scams and companies using deepfake audio, or even before, like using spoofed emails that were quite effective. And actually reading that, like, you know, the trick there, I'm like, I can totally see how like an accounting department falls for that and thinks, oh, it's their boss in a hurry. And then imagine that with a voice of like, you know, CEO.

12:26 Yeah, it's so scary. Exactly. Yeah. So I'm going to link to the video, you all can watch it. I'm also linking to the software that did this. Apparently, it uses something called transfer learning from speaker verification to multi speaker text to speech synthesis. And that even has an acronym SV2TTS, of course. And so this was based on someone's thesis. And you can watch the the video and get a good sense. But yeah, you just imagine like, I call I somehow get the number of the CEO and I call them up and I record that call. And then I take their I don't need only five seconds or so with their voice. And then I take that and I use some text to like real time generator, I'll call up the accounting department and say, hey, this is so and so we got a super emergency. We really important client, we forgot to pay them. We owe them $10,000. And you just like type and then replay what you type live back And then you overlay that with some background music, background noise, and just like, "Oh, I'm in a taxi right now.

13:25 Please get this done ASAP, otherwise we're in trouble.

13:28 Bye." Sometimes, but usually it doesn't work for email.

13:30 But if it's literally a voice that's interacting with you that sounds like the boss, well, it might work.

13:35 Hopefully we didn't give anyone ideas.

13:37 I guess you guys are better criminals than me.

13:38 I was just thinking a different version of Ferris Bueller's Day Off.

13:42 You could just use this to call in and excuse yourself from school.

13:45 Oh my gosh, you're right.

13:47 This would be beautiful when I was in middle school or high school.

13:50 Oh my goodness, yeah.

13:52 No, Michael's not feeling well.

13:54 Is he going to be okay?

13:54 He may be out tomorrow, but he'll be back pretty soon.

13:57 [laughter]

13:58 All right then.

14:00 Yeah, that's really horrible.

14:01 Maybe soon you'll have kids recording their parents' voices.

14:04 Yes.

14:05 I don't know which is worse, but these are all bad.

14:07 This is a good example of why, yes, a focus on ethics, when you're learning these technologies, is incredibly important, because we have that technology, and every developer should think about, "Okay, what's the impact of having this and using this?" And, "Okay, we can release it to really also, you know, make everyone aware that this exists." And, you know, we're talking about this right now, but still.

14:26 Yeah, I guess final thought on this one, Ines.

14:28 What do you think the chances of some sort of fingerprinting or like system that can determine that this was faked, right?

14:37 Like, not a human, but if I could take this and feed it to, say, another ML model that knows, like, the little glitches that show up in the system, Like, will we be able to verify stuff or not in the future?

14:48 -Or are we just lost? -I think so.

14:49 I think there have been some experiments where they tried that.

14:52 And another approach would be, okay, you can always encode things in the model that only show up under very, very certain circumstances.

14:59 So that's how you can watermark that model.

15:01 You can release that, and then if you say a very, very, very specific sequence, or if you type a nonsense sequence in there, it will always produce something nonsense but very differently.

15:13 And then you're like, ah, that's the system that was used.

15:15 And you know, that's how we can, it won't work on the output, but like, at least, you know, we can at least have some way of kind of finding out what type of system.

15:23 Yeah.

15:23 That's part of the ethics part, right?

15:25 Like that you, you embed these little watermarks rather than just like.

15:28 Put it out there.

15:29 I don't know.

15:29 It's, it's pretty scary to me, but I think as a society we'll come around to figure out what to do about it.

15:35 Yeah.

15:35 Cool.

15:35 Well, not scary is DigitalOcean.

15:37 I just want to tell you quickly about them and they're supporting the show.

15:40 So thanks to DigitalOcean, all of our software runs on top of DigitalOcean infrastructure.

15:45 You get the MP3s, it delivers either streams or downloads out of there, things like that.

15:49 So they're really, really great.

15:50 You can get started for as little as $5 per month for a server.

15:54 And they got a bunch of cool services, managed databases, load balancers and whatnot.

15:59 And it's not like EC2, which is so complicated, it could run Netflix.

16:03 It's like the simple thing that you just need to build your app and get it going.

16:06 So check them out at

16:10 And you get a $50 credit for new users there.

16:12 And definitely highly recommended.

16:14 Brian, what's this next one that you're working on here?

16:16 Okay, well, another contributed by a listener, this one from Andrew.

16:21 He contributed a little snippet that was on a Reddit stream.

16:26 And it was, I'm going to just guess, just describe it as abusing the pyproject.toml file by putting any file stuff in it.

16:35 So the example that he gave was you can have the pytest.ini file and the mypy.ini file or two any files for tools and you can, they're in any file format and TOML files kind of look like any files but they're not, they're different and you can break any with TOML syntax and you can break TOML with any syntax. However, you can write them such that they are, if you're careful, you can write them such that they comply with both.

17:04 And I went ahead and tried this out.

17:07 I was able to try putting pytest any like options within the toml file.

17:13 And, you know, both pytest and mypy do not support doing this, but they do support passing in a path of where their config file is.

17:22 And if you pass in the project.toml file, you can get it to work.

17:27 And if all you're trying to do is reduce the number of files in your project, yeah, this kind of works.

17:32 Why would you want to do that?

17:34 Just to try to reduce the number of files in your top level directory.

17:37 Okay.

17:38 I don't know, I should like use all of these like files more.

17:41 And I feel like you know, I love this idea of imagine if there was one config file, like really, you know, only one place where you put everything.

17:47 Also your dependencies, everything just goes in one file, and then you have that.

17:52 But for some reason, it's never actually worked out that way in practice, you can put it in the setup.cfg. That's a possibility. But they're both those are any file syntax also I have to admit like our product, our products don't even have a setup.cfg. We have a and then we have a requirements.txt.

18:07 Okay, I have a admission as well. Like I know we're talking about pyproject.toml, but I'm still just using requirements.txt as well for some of my projects. Because you know what the workflow works, I've got like external systems like pyup that are out there like automatically doing PRs for changes. I mean, it's just like, it's super cool. But at the same time, I already got a flow working. And I just, you know, Yeah, no, I can relate. And I use a ones, I think contributed a PI project Tomo to to spacey. And we were, you know, I really appreciated that, because I'm like, great. But it's still I don't think we can't really ditch requirements txt yet. And so now, we also have that. And now if we update, like a dependency, I have to manually edit that in three places.

18:50 Yeah, yeah, yeah. That's how it goes.

18:53 I'm on the bandwagon. I'm using Flit now, so I'm using pyproject.toml and Flit.

19:00 Okay, and that works cross-platform, cross-Python?

19:04 I don't know. It works for me.

19:06 Well, that's always good. Yeah.

19:08 I'm using it for mostly 3.6 and above, 3.6, 3.7, 3.8.

19:12 My personal projects, I think it's sufficient, and the ones I'm supporting for other people, I think it's fine for an individual project owner to say, I'm not supporting 2.7.

19:21 No, of course, I would never, you know, and I also would never go and just like whine about like, oh, there's, of course, there's like an edge case for 2.7 on Windows.

19:29 And there's something there, like, I understand it's not like as easy if like, you know, there was like the Python that could just like magically fix everything.

19:36 Yeah.

19:36 You know, I appreciate there's a lot of work that went into all of this. And it's like, yeah, something's a bit tricky.

19:41 One of the interesting things was

19:45 I use that a lot.

19:46 And it got-- there was a request to put pyproject.toml support on coverage.

19:52 The reason why it isn't there isn't because of any sort of like-- not that it would be cool, but the toml parsing is not part of the standard library.

20:02 And coverage has the strict policy that the only dependencies that it has are standard library dependencies.

20:09 That's a reasonable desire also.

20:11 Well, yeah, that's cool. You just get a cover shop, PY and just run the file or whatever, right?

20:15 Yeah, maybe we should get Toml support added to the standard library, and then it wouldn't be an issue.

20:20 There you go. Yeah, that's a whole different discussion. I know that's quite a heated debate about what should be on the standard library these days.

20:26 And the trend is less, not more, I think, if you take the poll.

20:29 Yeah.

20:31 Yeah, so some of the tools that you build are absolutely about making machine learning easier and do that across teams.

20:39 So I know that you really turned on to that space and pay a lot of attention.

20:42 So this polyaxone one that you found for our next item must be pretty interesting.

20:46 - Yeah, so basically it's actually quite funny because I obviously thought about what I was gonna talk about and had something else planned.

20:53 And then really earlier today, that release came out version 0.5 of polyaxone.

20:58 So I was like, okay, great, this is perfect.

21:00 It's like as if they'd waited for my podcast recordings.

21:05 Yeah, so basically we've been using polyaxone internally And essentially, it's a tool for experiment management.

21:11 So, you know, if you work in machine learning and you train your models, you have to like run tons of experiments and you have to, you know, you run an experiment, train a model, look at the results, then you stop it.

21:21 Then you tweak some other knobs, then you try again.

21:24 And you keep doing that until you have a good result.

21:26 And one thing we always do when we travel and like visit universities and research labs, we usually always ask them like, "Hey, how do you run your experiments?" And usually they're like, "Well, yeah, we got this GPU and it sits on my desk, and then I start an experiment, and then I sit around, and then I wait." And that's at some of the top labs and people where you'd think, "Oh, they must have everything taken care of, tons of money." It's like, "No, they're sitting there with their little GPU on their desk." And that's how it's done.

21:56 And basically, Polyaxon basically helps you solve this.

21:59 So it's built on Kubernetes.

22:01 It's very easy to set up, and especially if you're already set up with cloud computing, And you can also do stuff like hyperparameter search, where every hyperparameter is a tiny knob and you have tons of them, and then you want to find the one combination that gives you better accuracy.

22:17 And so you can run lots of experiments, see them in their little graphs and try things out.

22:23 So it's been a very great tool.

22:25 It's all open source, which is very much in our spirit.

22:28 And yeah, they just released 0.5, which comes with a plugin system, which is also great.

22:35 is very much in our spirit.

22:36 That's also how we like to do things with spaCy.

22:39 You can run it locally and it comes with some new features for chaining stuff together if your experiments have lots of steps.

22:46 So yeah, it's a great tool if you're working in the field.

22:49 - It looks super cool.

22:50 - Yeah, I can definitely recommend it.

22:51 - Yeah, so it's got a platform as a service offering, so you just kick it off and have it go, but also like on-premise enterprise option too, yeah?

22:59 That's cool.

23:00 - I think that's the focus.

23:01 It's like, you run it and then it gives you a little UI and you set it up yourself on your servers, and then it manages that.

23:08 Yeah, this looks really great.

23:09 Runs on Google's Kubernetes engine, among other things.

23:13 Probably on pretty much any Kubernetes cluster, I guess.

23:16 I haven't tried it.

23:17 Yeah, I think you might have to do a bit more set up if you're bringing your own, but it should be quite very straightforward.

23:24 Google actually makes this quite straightforward.

23:27 Yeah.

23:28 And another nice thing here is with a hyperparameter search, Like if you, yeah, most machine learning stuff is done on GPU, but not everyone has GPUs.

23:35 They're very expensive.

23:36 And we actually say it's not always the best choice necessarily, because if you just want to run lots of experiments, you can run them all in parallel.

23:43 You can run like thousands in parallel.

23:46 And then, you know, if you have a tool like Polyaxon that can help you do that, so you know, you don't have to kick them all off manually.

23:52 It's actually going to be much cheaper and much more efficient.

23:56 And you don't need a fancy GPU.

23:58 You can just run it on CPU.

23:59 Right. Yeah, the GPS are great, but they're much harder to come by. So that's cool. Yeah. Yeah.

24:04 It also has something about you can run on your laptop as well. Yeah, little data science is a box thing they talked about there at the end. So yeah, super cool. A nice one. All right, this last one I want to talk about here.

24:15 Actually, the way I got it onto my system is I use pipx. It's my pipx installed this thing called flint. So we've heard about linting. And we've heard about f strings. And I'm guessing some combination thereof is where the name of this thing called flint came from. It's quite new, it's not super popular yet, but it works really, really well. So the idea is I've got some code, maybe it's old code, maybe I just haven't bothered to write everything using f strings, and I would like to modernize it in its string processing. So this tool, what you can do is you can point it at a single Python file, or you can just point it as a directory, like a top level It'll just go to every, traverse the whole directory tree and find all the Python files and then rewrite all the string operations to be fstrings.

25:05 - Nice.

25:05 - And it does a pretty good job.

25:07 It'll do the percent, you know, Python two style formats as well as the dot format style.

25:14 And it'll just replace all those with fstrings.

25:16 There's a couple of things it doesn't do.

25:18 If it's like multi-line, really long stuff, it won't replace those.

25:23 And when I first tried it, it actually was making a mistake on digit grouping format.

25:28 So if you have curly braces, colon, comma, 'cause you want thousands, millions, grouping, and so on, that just went insane and broke my code.

25:37 But I submitted a bug over to the guy who's working on it, fixed it, I believe a new release is already out.

25:43 So that shouldn't be there, but just, you know, run it on something you have under source control and just look at the lines that have changed before you do the commit or run your test, - Yeah, well, such a good open source user, like, you know, found a bug, you know, reported it probably with like a nice description, fixed.

26:01 - I'm like, I ran this on all of Talk Python Training and all of Python Bytes and some of it broke.

26:06 So what I found out is it's exactly this.

26:08 If it has digit grouping, it broke.

26:10 And so then they fixed it, but it was no big deal.

26:12 I think I converted about 500 to 700 string formats over to fStrings.

26:18 And it just, it's cleaner, shorter, nicer.

26:21 The thing with f-strings is I always, I don't know if you all use it, I'll ask you in a sec, but I'm always like, okay, I'm going to write the string.

26:28 I'd say, quote, type, type, type.

26:30 Oh, I want to put something in here.

26:32 Curly brace.

26:33 I wish I would have done the F.

26:35 Back, back, back, back, back, back, back, put the F.

26:37 And then back, back, back, back, back, and then type the thing.

26:39 I'm like, well, that was more work than just dot format 'cause the IDE will auto-complete as dot F and then boom.

26:44 So a lot of times I end up using the format anyway, but I still prefer to have the f-strings and read them.

26:49 So this way I can write it however I want and then just hit it with this before I do a check-in.

26:53 - I think that we should ask VS Code and PyCharm to detect when we put a curly brace in a string and automatically add the F.

27:00 - Yes, just like a hotkey.

27:01 - I was going to say the exact same thing, so it's not. (laughs)

27:05 - That's awesome, you all are in the same boat.

27:07 So yeah, this is really cool.

27:08 I definitely think my code is nicer.

27:11 I originally created, like when I created the Python Bytes website and I created the Top Python Training, this was when the latest version of Python on Ubuntu was 3.5, So we didn't have fstrings.

27:21 And I actually took the server down once on accident, because I used an fstring in a little utility file that was in the same directory in the scanning path, looking for the routes, found that, couldn't parse it, and the website couldn't start.

27:33 I'm like, "Why is it down? What have I done?

27:35 I didn't even change it." So anyway, I'm really happy now that I can just take all that code that I used to leave in the format style and just flint, space, just run in this directory, boom, it's done.

27:45 So yeah, it's really nice.

27:47 I can't wait to just intuitively just use fstrings and all that stuff. It's still kind of, I don't know, just ingrained in my brain.

27:53 Like even, I know I go to conferences and I see people use all the new syntax and I'm like, "Yeah, oh, that's so nice." But it's just like, you know, in my day-to-day work, you know, even if we don't support 2.7, we support 3.5 and they're just like a lot of these.

28:07 Yeah, exactly. You know, there is this thing called, I can't remember what it was called, Brian, we covered it, where it lets you add fString support to Python 2. It may also work for Python 3.5. You can definitely retroactively add f-strings to the format. It's some weird way.

28:24 But then you need like another runtime dependency, which...

28:26 Yeah, yeah. It's not worth it. It does some weird thing.

28:29 That's how it works. Yeah, that's a bit unattractive.

28:30 It like rewrites like the file loader with a certain weird encode. It's like, it's pretty sketchy.

28:37 Yeah. Okay. Now I wouldn't want to ship that in like our libraries.

28:39 Oh, come on. Why not?

28:41 Just run your tests, make sure they pass. It's good.

28:44 Yeah, good.

28:45 It's cool that something like this is out so that when you decide we're no longer supporting 3.5, you just hit it with this and a quick scan through the files and it's f-stringified.

28:53 That's going to be so nice. I can't wait. All that and all the type hints. Once we can drop all of the older versions, it can be so nice. I won't even mind rewriting all of Occult. I think with our team, we're just going to sit down and be like, "Yay, let's do this." We're going to do it. Yes, here it comes.

29:11 It's going to be so satisfying, years later.

29:14 - Yeah, well, it's the curse of success, right?

29:16 You have so many people using your libraries that you just gotta keep it sort of a little bit backwards.

29:20 - Yeah, sure, and like some people are still stuck on legacy code.

29:23 Like, I mean, I'm not, it's not, you know, some people like look down on like companies that are still on like Python 2, but it's like, you know, it's not like many of them like really enjoy using all this legacy software and legacy like stuff.

29:35 They're just like, it just exists and we might as well keep supporting it if we can.

29:40 - Yeah, what's the Python 2 story for you all?

29:42 you're still supporting it for now?

29:44 - Yeah, and I think we will for a while.

29:45 - After January?

29:46 - Yeah, we probably will.

29:48 There will just naturally be a point where we cannot upgrade any of our dependencies.

29:52 Like, I don't know, NumPy, for example.

29:54 Okay, if we ever, you know, it is a good reason why we want to use a newer version of that, we just can't.

30:00 And if everyone else drops it, we just have to be like, okay, that's it.

30:03 We can't.

30:04 And it's also not like the old versions are going away.

30:06 Like, if we make sure we don't have any major bugs, you can still use an old version of spacey and like, we're not going to take that away from you.

30:14 - Right. Just pin the version and you'll be good.

30:16 - Yeah.

30:17 - Very cool. Very cool.

30:18 All right. Well, that's it for all of our main items.

30:20 Brian, you want to, I know we've got a few little extra things just thrown here at the end.

30:23 Do you want to kick it off?

30:24 - Yeah. So we had an email from Andre Janish.

30:26 I think that's how you say his name.

30:28 Saying that we were, in one of our episodes we talked about regular expressions taking down, now I even forgot, took down something.

30:35 - It was something major. Yeah.

30:37 I can't remember, - A major cloud provider went down because of it, yeah.

30:40 - And how that could happen, so there's an interesting video talking about regular expression denial of service attacks and how it happens.

30:48 It was just an interesting video.

30:50 We'll have a link to it in the show notes if anybody wants to watch.

30:52 - Okay, yeah, yeah, super cool.

30:54 So I got a couple I wanna throw out there.

30:56 One is if you're doing any work where you're working with microservices or you want to have some kind of application that's talking to some API endpoint, you want to debug it, There's a new thing called HTTP toolkit, and it has like special Python support.

31:14 So this is like a proxy you can run on your computer and say start recording, and it'll start recording all the requests that you're making.

31:22 So it integrates with urllib.request, urllib2, request, pip, Python 2 and 3, photo, all those things, and specifically catches traffic from those.

31:33 And it does interesting stuff by like changing the Python path and environment variables.

31:39 And then all of these libraries that I talked about apparently respect certain proxy settings and things you can set.

31:45 So you don't have to change your app at all.

31:47 You just start a terminal with HTTP toolkit and then run your code and it can record it.

31:52 - That's cool.

31:53 - Yeah, so if you're like, why is this crashing?

31:55 You know, I run my request thing and then I get some kind of crash and how am I supposed, you don't have the developer tools in your web browser to look at the headers and whatnot.

32:06 So you can do it with this, it's pretty cool.

32:08 It's free, but there's also a paid version, just a heads up.

32:10 Also, there's a nice little link.

32:13 Last time, time before, Brian, we were talking about magic, Python magic.

32:17 You're like, well, that's a pretty strong, strong name to be magic.

32:22 And all it does is detect file types.

32:24 Right, you remember that thing?

32:26 David Martinez said, well, the reason it's called magic is there's basically these magic number signatures that appear at the beginning of files, and that teaches you about the syntax.

32:39 So, for example, if you had a SQLite file, it would start with 53, 51, 4C, 69, etc.

32:44 If you see those numbers up the front, that means SQLite, right?

32:47 So, do you actually know this by heart?

32:49 Or did you write this down?

32:51 No, no. I opened it up.

32:54 Of course, yeah, I know that one, sure.

32:55 No, I just unfolded it up.

32:57 Let's see.

32:58 Really quickly, Python 3.7.4 is out.

33:01 So I brew and upgraded my Python 3.7, which is how I'm getting on my machine.

33:06 And it's already on homebrew as well.

33:08 So that was like, I don't know, six, seven hours delay there.

33:11 It was really nice to see that come out real quick.

33:12 - Or if you have pyenv, you can do pyenv.

33:15 I don't even know the command, but like install something and then--

33:18 - Right away have it, that's awesome, yeah.

33:21 And then the last one, I want to point out this thing called flying.

33:24 I just call it flying fractals.

33:26 But this person put together this project using pywonderland and it automates some other libraries that are based on C.

33:36 So they made some really cool videos of like flying through three dimensional, like animated Mandelbrot sets and other kinds of stuff.

33:45 And I just, when I was just watching, I thought just, wow, this is super cool computational stuff over here.

33:51 I've done a bunch of work in like complex dynamics and like trying to visualize that and like this kind of blew me away.

33:56 So if you care at all about that stuff, I think you'll just enjoy like a minute of that video.

33:59 - Yeah, yeah.

34:00 So yeah, actually you might've actually noticed that my voice still isn't like 100% and it's a bit rough.

34:06 And that's because last weekend we had our very, very first conference here in Berlin called Spacey IRL, like, you know, Spacey in real life.

34:14 So our community came together and I'm still like absolutely blown away.

34:19 Like there was, you know, the vibe was amazing.

34:20 We had like 200 people there and a lovely like old theater, 12 really amazing talks by people from research, industry, community. So it was really a lot of fun and all talks were recorded and we're currently uploading them to our YouTube channel. So probably by the time this airs, they might have already been released and yeah, it'd be a bunch of, yeah, if you're interested in natural language processing, spacey, those, the talks are really, really great. And, yeah, I hope you, you enjoy watching them.

34:46 And that's awesome. I'm so glad you're putting them on YouTube and wow, congratulations.

34:50 You must be just blown away at how awesome it is to put on a conference about your own stuff, right? And so many people came and the energy and like you could tell your voice was gone. It's great.

34:59 I know that was like, yeah. And it was also it's actually quite refreshing to organize your own conference. Like, you know, we were like, okay, let's do all the things that we think a conference should do and like try them out. And it actually worked quite well.

35:11 Like, you know, only one track, for example, stuff like that. No questions from the audience, much more social time, some really healthy food, stuff like that. So it was it was it It was great. My voice suffered a bit, but we're giving a lot back to the community, as in the videos, photos, stuff.

35:27 Yeah, sounds great. Awesome. Congratulations.

35:30 Couple of episodes ago, Brian actually talked about FastAPI, not to be confused with FastAI, which I talked about earlier. So yeah, it's a great, very modern, cool Python library for REST APIs. And we're like, yeah, we've been big fans. We've started switching all all our APIs over.

35:47 The exciting news here is that their core developer, Sebastian Ramirez, is actually going to join our team here in Berlin.

35:54 This means a lot of cool development for us.

35:56 But also, we obviously, since we love the FastAPI project, we'll keep supporting that.

36:01 And we'll definitely give him enough time to keep working on it.

36:03 That's great news.

36:04 We found him through the project.

36:05 We saw, oh, he's doing some consulting work.

36:07 We're like, hey, we'd love to work with him.

36:09 And one thing came to another.

36:11 And now, yeah, he'll be part of our Explosion team, which is still growing, by the way.

36:14 So we've been very lucky that we were able to work with more people and expand our team.

36:19 Yeah, that's so cool that your business is growing.

36:22 And I guess it's worth pointing out that back on Talk Python, to me, we talked about explosion AI.

36:29 I interviewed you about building a software business.

36:31 So back on episode 202.

36:32 So, you know, this is just like more evidence that that's all good advice.

36:36 Thanks.

36:36 Yeah, super cool.

36:38 Well, great, great news.

36:39 I guess it's probably time for a joke here too.

36:42 A pie joke, if you will, maybe.

36:44 So I think this, I'll do the first one.

36:46 This one I think came from PyJokes.

36:48 We'll see.

36:49 We're starting to run that well dry, so I suggest people send in your jokes, please.

36:53 But a programmer walks into the bar and orders 1.38 root beers.

36:58 The bartender informs her that it's a root beer float.

37:03 She says, "Nah, make it a double." All right, it's a pretty bad type system.

37:06 Maybe it doesn't work so well in Python.

37:08 Like we don't care so much about types, but you know, still, so it's all right.

37:11 - I like it.

37:11 - All right, we got one more up here.

37:12 Who put this one in, Brian?

37:14 Yeah, so just last night I was researching for this podcast, writing notes for the other podcast and working on an open source project and I came up with this.

37:24 What do you call a developer without a side project?

37:27 Well rested.

37:28 Yeah, that's true.

37:29 It's almost a bit sad in that sense.

37:32 I know it's too real.

37:36 I shouldn't be complaining.

37:39 I shouldn't be complaining.

37:41 But you know, there are some comments we could make here about the culture and what's expected of developers these days and how that's maybe not ideal.

37:49 You know, sleeping enough, stuff like that.

37:52 Oh, definitely.

37:53 People should be.

37:54 And it's mostly a self-reflection.

37:55 No, I mean, it is a good joke.

37:57 I wasn't criticizing your joke.

38:00 It's a totally fine joke.

38:01 I'm just saying it's very real.

38:02 You know how jokes can be too real and then you're like, "Oh." Yeah, I'm really uncomfortable now.

38:09 Exactly. All right. Well, I think that's a good place to leave it. Brian, thank you as always.

38:15 Thank you.

38:16 Denis, it was great to have you here. Thanks for coming.

38:17 Yeah, thanks. Bye.

38:18 Bye.

38:19 Thank you for listening to Python Bytes. Follow the show on Twitter via @PythonBytes. 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 Okken, This is Michael Kennedy.

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

Back to show page