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

« Return to show page

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

Recorded on Thursday, Jul 11, 2019.

00:00 KENNEDY: Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your ear buds. This is Episode 139, recorded July 11th, 2019. I'm Michael Kennedy.

00:11 OKKEN: And I'm Brian Okken.

00:12 KENNEDY: And I want to welcome Ines Montani to the show. Ines, great to have you here. Special guest, going to help us cover the news of the week. Thanks for being here.

00:19 MONTANI: Yeah, thanks for having me. I'm really excited.

00:21 KENNEDY: It's going to be really fun to have you participate in this. Also thank you to DigitalOcean for sponsoring this episode. Check them out at More on that later. Brian, we've talked a lot about how do you install Python, how do you manage Python, how you upgrade your stuff. There's just so many ways, and then we've got things like pipenv, flit, poetry, it goes on and on, and it still goes on, right?

00:43 OKKEN: This was a contribution from Nils de Bruin sent us this. There was an article called "Simplify Your Python Developer Environment" and it talked about using pyenv, pipx, and pipenv together. And my first reaction was we've already covered all these. However, I have tried pipx. Actually, I did the joke, the pyjokes, I did that with pipx, and I've tried pipenv once before. It doesn't really do anything for me that I really need. And the pyenv, I've tried it, and it didn't work for me. So actually, all these things, I kind of wanted to give 'em another shot anyway, so I went ahead and read this article, and it actually is pretty nice. It's a nice pros and cons of all the tools and how to set 'em up. 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. So if people don't remember, pyenv is used to install and manage multiple python versions and flavors on a computer, 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. And then pipenv is for when you're working on a project, on an application, it's a way to manage virtual environments and dependencies on a per project basis.

02:07 KENNEDY: These are really interesting, because I feel like often they kind of blend, kind of blur together, right? You're like, well, I know there's all these env things I could use and whatnot, and it's like, well, when should I use what and what one is relevant for the situation? What do you think, Ines?

02:22 MONTANI: It actually took me a second to, like, remember the one that I've used. So I'm totally in the market for stuff like that. But actually, I haven't heard of pipx at all, but I think, yeah, pyenv I definitely use, 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. And I'm, as a library developer, we need to build stuff for, Python 2. We're supporting Python 2.7 and 3.5.

02:45 KENNEDY: Just so folks know, like, you're deeply involved with Spacy and some tools built on top of that, the Natural Language Processing, which will become evident as we go through some of your topics some more, but maybe not everyone knows your background. But I feel like pyenv is most relevant for people building libraries, and pipenv is really relevant for people building applications. I don't know. What do you think, Brian?

03:09 OKKEN: Both of 'em are important for people like us that have to do both. I have a question for Ines. The pyenv, so 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 tox build to be able to access all of 'em?

03:28 MONTANI: 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 venv to create my virtual environment, and then they are created with whichever Python version I've configured locally. So I do, like, if I have local 2.7, an individual environment will have 2.7 in it.

03:49 OKKEN: Okay. Well, I'll give it a shot.

03:50 KENNEDY: Yeah, yeah, it's 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. So, for example, I have, like, cookie cutter. I have the httpie library. I have glances. I have pyjokes, of course, because we run this podcast, and some other stuff that I'll even talk about later, like ptpython.

04:19 MONTANI: Is that a bit like pex files, or is that something else?

04:22 KENNEDY: It's a little, a little bit. What it does is when you say I want to have, let's say I want the utility ptpython, which is, like, an Emacs-enabled REPL, basically. 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 could use. So what you can do is you can pipx install ptpython, and then it just, it automatically puts it in a location, modifies your path so that it's, it has its own virtual environment, it upgrades itself and its dependencies separately, but anytime I want, I can just type ptpython and go crazy, or glances, or pyjoke, or whatever.

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

04:58 KENNEDY: It's really nice. You 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 MONTANI: Oh, yeah. Wonder if we shouldn't 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 KENNEDY: All it does is build upon pip. So if you can pip install a thing and it has an entry point, then you can pipx install it, as well.

05:21 MONTANI: Ah, okay. Cool.

05:23 KENNEDY: 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?

05:29 OKKEN: 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 and, yeah, it's a mess.

05:43 MONTANI: Classic.

05:44 KENNEDY: Ooh yeah, it's nice. Definitely for people who are 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 MONTANI: This week was actually, or the past few weeks were actually super exciting also in my field. So there was a new release of a course for Natural Language Processing. So is a very popular free online course for deep learning by Rachel Thomas and Jeremy Howard, and it also comes with a Python library. It comes with lots of notebooks, really active community. So if you want to get into the modern machine learning stuff, that's 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, ULMFIT, 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, and what I thought was really interesting and really cool about it is that it of course covers the modern neural network approaches and all the very hip stuff, but it also focuses on traditional techniques, so just the whole background of, okay, what did people do before deep learning? Topic modeling, linear models, just really all the basics, and even 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, like, in real life and in real-life practical applications, that's super important, and you can do a lot with that that, you know, really gets the job done. 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 the topic of, okay, think about the impact that the work you'll be doing has, and I thought that was incredibly refreshing. And of course, disclaimer, I haven't actually watched all the videos yet. I don't even think that's, physically possible to do all of that since it was released.

07:36 KENNEDY: It's too new and it's too long, yeah, uh-huh.

07:38 MONTANI: Yeah, it's a lot of material, but yeah, I really like the work they're doing, and it's a very, very significant release. And it's all free.

07:45 KENNEDY: Yeah, it's super cool, yeah. 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?

07:54 MONTANI: Yeah, and there are lots of notebooks, so you can open the same notebooks, you can play through the examples, and of course, also use their library to really work through the things efficiently, yeah.

08:04 KENNEDY: Sure, that's super cool. Does it cover any of the libraries that you all work on, like Spacy or anything?

08:09 MONTANI: Spacy's a much more high-level toolkit and framework, so it's like, this is really the basics of the technology. So while the 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, yeah, you kind of take that or you plug in your own.

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

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

08:59 KENNEDY: 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 MONTANI: Yeah, and especially then some people really, you know, then they start throwing a neural network model at it, when actually, the best solution would've been to just write one regular expression. I don't know, you work at a company and you have a statistical model that recognizes organization names, and 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, and that will likely take you five minutes and is much more effective in the real world, so, yeah.

09:43 KENNEDY: This is the practical applied Natural Language Processing, right? Speaking of language, this next item that I want to talk about, I don't know, it just scares me. So let me tell you quick about it. I'll get your two opinions. The idea is that we can clone the human voice by giving it a sample, by using some sort of a neutral network type thing. I'm not sure exactly. So this was sent in by Brendan. Thank you for sending that over. And in just a couple minutes, you can load up somebody's voice, use some Python, a pre-trained machine learning model, and then type in text. It will speak whatever that text is in the voice of that person. And this is just, I don't know. I feel like public discourse is in serious jeopardy here. What do you all think?

10:27 OKKEN: This is pretty interesting, and I was a little frightened, actually, watching this video of 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 KENNEDY: That'd be pretty funny.

10:47 MONTANI: Yeah. Normally I think I would say, I think it's still quite compute-intensive 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 is a 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 now also voice audio.

11:09 KENNEDY: Right, I mean, we've heard of the deep fake stuff for videos and whatnot, and that's kind of scary, but this is, it's almost like this could be worse, right? I could 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 it's pretty close.

11:41 MONTANI: But I think it would 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, like recordings or videos, much less seriously. I do think it will develop into a culture where we don't necessarily trust an audio recording because it could've been produced by something like this. But I do think just for very everyday life scam, I think it's very timely, because yeah, there are all these news articles about all these financial scams and companies using deep fake audio, or even before, using spoofed emails that were quite effective. And actually reading that, you know, the trick there, I'm like, I can totally see how an accounting department falls for that and thinks, oh, it's their boss in a hurry. And then imagine that with a voice of a CEO.

12:25 KENNEDY: Yeah, it's so scary. Exactly, yeah. So I'm going to link to the video. You all could 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, whew. And that even has an acronym, SV2TTS, of course. And so this was based on someone's thesis, and you can watch the video and get a good sense. But yeah, you can just imagine, like, I call a, I somehow get the number of the CEO and I call them up and I record that call, and then I take their, like, I need only five seconds or so of their voice, and then I take that and I use some text to real-time generate. I'll call up the accounting department and say, hey, this is so-and-so. We've got a super emergency with a really important client. We forgot to pay them. We owe them $10,000. And you just type and then replay what you type live back to 'em, like...

13:18 MONTANI: Yeah, and then you overlay that, yeah, with some background music, background noise, and just like, oh, I'm in a taxi right now.

13:24 KENNEDY: Exactly.

13:25 MONTANI: Like, please get this done ASAP, otherwise we're in trouble, bye.

13:28 KENNEDY: Sometimes what usually doesn't work for email, but if it's literally a voice that's interacting with you that sounds like the boss, well, it might work. Hopefully we didn't give anyone ideas.

13:37 OKKEN: I guess you guys are better criminals than me. I was just thinking, like, a different version of "Ferris Bueller's Day Off." You could just use this to call in and excuse yourself from school.

13:46 KENNEDY: Oh my gosh, you're right. This would be beautiful when I was in middle school or high school. Oh my goodness, yeah. No, Michael's not feeling well. Is he going to be okay? He may be out tomorrow, but he'll be back by... All right then. Yeah, and that's really horrible.

14:01 MONTANI: Yeah, I mean, pretty soon you have kids recording their parents' voices and then...

14:04 KENNEDY: Yes. I don't know if that's worse, but these are all bad.

14:07 MONTANI: This is a good example of why, yeah, so 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 make everyone aware that this exists. And we're talking about this right now, but still, yeah.

14:26 KENNEDY: Yeah, I guess final thought on this one, Ines. What do you think the chances of some sort of fingerprinting or system that can determine that this was faked, right? Not a human, but if I can take this and feed it to, say, another ML model that knows the little glitches that show up in the system, will we be able to verify stuff or not in the future? Are we just lost?

14:49 MONTANI: I think so. I think there've been some experiments where they tried that. And, I mean, another approach would be, okay, you can always encode things in the model that only show up under very, very certain circumstances, so that's how you can watermark that model. You can, or 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, and then you're like, ah, that's the system that was used, and that's how we can... It won't work on the output, but at least we can at least have some way of kind of finding out what type of system...

15:23 KENNEDY: Yeah, that's part of the ethics part, right? Like, that you embed these little watermarks rather than just put it out there. I don't know, it's pretty scary to me, but I think as a society, we'll come around to figure out what to do about it. Yeah, cool. Well, not scary is DigitalOcean. Just want to tell you quickly about them, and they're supporting the show, so thanks to DigitalOcean. All of our software runs on top of DigitalOcean infrastructure. You get the mp3 the stream delivers, either stream or download data there. Things like that. So they're really, really great. You can get started for as little as $5 per month for a server, and they got a bunch of cool services, managed databases, load balancers, and whatnot, and it's, you know, it's not like EC2, which is so complicated it can run Netflix. It's the simple thing that you just need to build your app and get it going. So check them out at, and you get a $50 credit for new users there, and definitely highly recommended. Brian, what's this next one that you were working on here?

16:16 OKKEN: Okay, well, another contributed by a listener, this one from Andrew. He contributed a little snippet that was on a Reddit stream, and it was, I'm going to just guess it, just describe it as abusing the pyproject.toml file by putting ini file stuff in it. So the example that he gave was you can have the pytest.ini file and the mypy.ini file are two ini files for tools, and you can, they're in ini file format, and toml files kind of look like ini files, but they're not. They're different. And you can break ini with toml syntax, and you can break toml with ini syntax. However, you can write them such that they are, if you're careful, you can write 'em such than they comply with both. And I went ahead and tried this out. I was able to try putting pytest.ini options within the toml file, and both pytest and mypy do not support doing this, but they do support passing in a path of where their config file is, and if you pass in the project.toml file, you can get it to work. And if all you're trying to do is reduce the number of files in your project, yeah, this kind of works.

17:32 MONTANI: Why would you want to do that?

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

17:37 MONTANI: Okay. I don't know, I should use all of these files more, and I feel like I love this idea of imagine if there was one config file, really only one place where you put everything, or so your dependencies, everything just goes in one file, and then you have that, but for some reason, it's never actually worked out that way in practice.

17:55 OKKEN: You can put it in the setup.cfg. That's a possibility. But they're both, those are ini file syntax, also.

18:01 MONTANI: I have to admit, our projects don't even have a setup.cfg. We have a and then we have the requirements.txt.

18:08 KENNEDY: 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. You know what? The workflow works. I've got external systems like pyup that are out there 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.

18:30 MONTANI: Yeah. No, I can relate, and a user once I think contributed a pyproject.toml to Spacy, and we were, you know, I really appreciated that, because I'm like, great. But it's still, I don't think, yeah, we can't really ditch requirements.txt yet, and so now we also have that, and now if we update a dependency, I have to manually edit that in three places.

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

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

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

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

19:06 MONTANI: Well, that's always good, yeah.

19:08 OKKEN: I'm using it for mostly 3.6 and above, 3.6, 3.7, 3.8. For 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." so...

19:22 MONTANI: No, of course, I would never, and I also would never go and just whine about, oh, of course there's an edge case for 2.7 on Windows, and there's something there. I understand it's not as easy if, you know, there was the Python that could just magically fix everything. You know, I appreciate there's a lot of work that went into all this and is like, yeah, some things are a bit tricky.

19:41 OKKEN: One of the interesting things was I use that a lot, and it got, there was a request to put pyproject.toml support on Coverage. The reason why it isn't there isn't because of any sort of, not that it would be cool, but the toml parsing is not part of the standard library, and Coverage has this strict policy that the only dependencies that it has are standard library dependencies. That's a reasonable desire, also.

20:11 MONTANI: Well, yeah, yeah.

20:12 KENNEDY: Yeah, that's cool. You just get and just run the file or whatever, right?

20:15 OKKEN: Yeah, maybe we should get toml support added to the standard library. Then it wouldn't be an issue.

20:20 KENNEDY: There you go. Yeah, that's a whole different discussion. I know that's quite a heated debate about what should be in the standard library these days. The trend is less, not more, I think, if we take the poll. Yeah, so Ines, some of the tools that you build are absolutely about making machine learning easier and doing that across teams. So I know that you're really turned on to that space and paying a lot of attention. So this Polyaxon one that you found for our next item must be pretty interesting.

20:46 MONTANI: Yeah, so basically, it's actually quite funny because I've obviously thought about what I was going to talk about and had something else planned, and then really today, earlier today, that release came out, version 0.5 for Polyaxon. So I was like, okay, great, this is perfect. It's as if they'd waited for my podcast recordings. Yeah, so basically, we've been using Polyaxon internally, and essentially it's a tool for experiment management. So if you work in machine learning and you train your models, you have to 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. Then you tweak some other knobs. Then you try again, and you keep doing that until you have a good result. And one thing we always do when we travel and visit universities and research labs, we usually always ask them, hey, how do you run your experiments? And usually they're like, well, yeah, you know, 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 the top, some of the top labs and, you know, people where you'd think, oh, they must have everything taken care of, tons of money, and it's like, no, they're sitting there with their little GPU on their desk, and that's how it's done. And basically, Polyaxon basically helps you solve this. So it's super, you know, it's built on Kubernetes. It's very easy to set up, and especially if you're already set up with cloud computing, and yeah, and you can also do stuff like hyperparameter search, where every hyperparameter's a tiny knob and you have tons of them, and then you want to find the one combination that gives you better accuracy. And so you can run lots of experiments, see them, you know, and their little graphs, and try things out. So it's been a very great tool. It's all open source, which is very much in our spirit. And yeah, they just released 0.5, which comes with a plugin system, which is also great. It's very much in our spirit. That's also how we like to do things with Spacy. You can run it locally and, you know, it comes with some new features for chaining stuff together if you have, your experiments have lots of steps. So yeah, it's a great tool if you're working in the field.

22:49 KENNEDY: It looks super cool.

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

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

23:00 MONTANI: I think that's the focus. It's like, you know, you run it, and then it gives you a little UI and you're just like, you set it up yourself on your service, and then it manages that.

23:08 KENNEDY: Yeah, this looks really great. Runs on Google's Kubernetes Engine, among other things, but probably pretty much any Kubernetes cluster, I guess. I haven't tried.

23:17 MONTANI: Yeah, I think you might have to do a bit more setup if you're bringing your own, but it should be quite basic for, Google actually makes this quite straightforward. And yeah, and another nice thing here is with the hyperparameter search, if you, yeah, most machine learning stuff is done on GPU, but not everyone has GPUs. They're very expensive. And we always 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. You can run thousands in parallel. And then if you have a tool like Polyaxon, that can help you do that so you don't have to kick them all off manually. It's actually going to be much cheaper and much more efficient, and you don't need a fancy GPU. You can just run it on CPU.

23:59 KENNEDY: Right, yeah. GPUs are great, but they're much harder to come by, so that's cool. Yeah, it also has something about you can run it on your laptop, as well, right? The little data science in the box thing they talk about there at the end. So yeah, super cool. It's a nice one. All right, this last one I want to talk about here, actually, the way I got it onto my system is I used pipx. So I pipx installed this thing called flint. So you've heard about linting, and we've heard about fstring, 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 fstring, 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 at the directory, like, a top-level directory. It'll just go to every, and traverse the whole directory tree and find all the Python files and then rewrite all the string operations to be f-strings.

23:59 MONTANI: Nice.

23:59 KENNEDY: And it does a pretty good job. It'll do the percent, you know, Python 2 style format, as well as the dot format style, and it'll just replace all those with f-strings. There's a couple things it doesn't do. If it's multi-line, really long stuff, it won't replace those, and when I first tried it, it actually was making a mistake on digit grouping format. So if you have curly braces colon comma because you want thousands, millions grouping, and so on, that just went insane and broke my code. But I submitted a bug over to the guy who's working on it, fixed it, I believe the new release is already out, so that shouldn't be there. But just 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 tests, something like that.

23:59 MONTANI: Yeah, wow, such a good open source user. You know, found a bug, reported it, probably with this description, fixed.

23:59 KENNEDY: I'm like, I ran this on all of Talk Python Training and all of Python Bytes, and some of it broke, so what I found out is it's exactly this. If it had digit grouping, it broke, and so then they fixed it. But it was no big deal. I think I converted about 500 to 700 string formats over to f-strings, and it just, it's cleaner, shorter, nicer. 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 this string out, say quote, type type type, oh, I want to put something in here, curly brace. Oh, I wish I would've done an f. Back back back back back back back, put the f, and then back back back back back and then type the thing. I'm like, well, that was more work than just dot format, 'cause the ID you autocomplete, it's like .f and then boom, like, so a lot of times I end up using the format anyway, but I still prefer to have the f-strings and read them. So this way I can write it however I want and just hit it with this before I do a check-in.

23:59 OKKEN: I think that we should ask VSCode and PyTerm to detect when we put a curly brace in a string and automatically add the f.

23:59 KENNEDY: Yes, just like a hotkey.

23:59 MONTANI: I was going to say the exact same thing, so it's not...

23:59 KENNEDY: That's awesome. You all are in the same boat. So yeah, this is really cool. I definitely think my code is nicer. I originally created, like, when I created the Python Bytes website and I created Talk Python Training, this was when the latest version of Python on Ubuntu was 3.5, so we didn't have f-strings. 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 and the scanning path looking for the routes found that, couldn't parse it, and the website couldn't start. I'm like, why is it, what have I done? I didn't even change it. So anyway, I'm really happy now that I could just take all that code that I used to leave in format style and just flint space, you know, and just run on this directory, boom, it's done. So yeah, it's really nice.

23:59 MONTANI: I can't wait to just intuitively just use f-strings and all that stuff. It's still kind of, I don't know, just ingrained in my brain. Like, even, I don't know, 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 there are just a lot of these...

23:59 KENNEDY: 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 in some weird way.

23:59 MONTANI: But then you need another runtime dependency, which...

23:59 KENNEDY: Yeah, it's not worth it. It does some weird thing...

23:59 MONTANI: That's how it works, yeah. That's a bit unattractive.

23:59 KENNEDY: It rewrites the file loader with a certain weird encode. It's like, it's pretty sketchy.

23:59 MONTANI: Yeah, okay, no, I wouldn't want to ship that in our libraries.

23:59 KENNEDY: Oh, come on, why not?

23:59 OKKEN: Just run your tests, make sure they pass, and it's good.

23:59 MONTANI: Yeah, good.

23:59 KENNEDY: But it's cool that something like this is out so that when you decide, like, we're no longer supporting 3.5, you just hit it with this and, like, you know, a quick scan through the files and it's fstringified.

23:59 MONTANI: That's going to be so nice. I can't wait. I mean, all that and all the type hints.

23:59 KENNEDY: Yes.

23:59 MONTANI: You know, once we can drop all of the older versions, oh, it can be oh so nice. So yeah, I'm really, I wouldn't even mind rewriting all the code. I think with our team, we're just going to sit down and be, yeah, let's do this, and...

23:59 KENNEDY: We're going to do it. Yeah, here it comes.

23:59 MONTANI: Yeah, it's going to be so satisfying. Like, years later.

23:59 KENNEDY: Yeah, well, it's the curse of success, right? You have so many people using your libraries that you've just got to keep it for a little bit backwards.

23:59 MONTANI: Yeah, sure. Some people are still stuck on legacy code. Some people look down on companies that are still on Python 2, but it's like, you know, it's not like many of them really enjoy using all this legacy software and legacy stuff. They're just, it just exists, and we might as well keep supporting it if we can.

23:59 KENNEDY: Yeah, what's the Python 2 story for you all? You're still supporting it for now?

23:59 MONTANI: Yeah, and I think we will for a while.

23:59 KENNEDY: After January?

23:59 MONTANI: Yeah, we probably will. There will just naturally be a point where we cannot upgrade any of our dependencies. I don't know, numpy, for example. Okay, if we ever, you know, there is a good reason why we want to use a newer version of that, we just can't.

23:59 KENNEDY: Right.

23:59 MONTANI: And if everyone else drops it, we just have to be like, okay, that's it, we can't. And it's also not like the old versions are going away. If we make sure we don't have any major bugs, you can still use an old version of Spacy, and we're not going to take that away from you.

23:59 KENNEDY: Right, just pin the version and you'll be good. Yeah, very cool, very cool. All right, well, that's it for all of our main items. Brian, you want to, I know we got a few little extra things to just throw in here at the end. You want to kick it off?

23:59 OKKEN: Yeah, so we had an email from Andre Jaenisch. I think that's how you say his name. Saying that we were, in one of our episodes, we talked about regular expressions taking down... Now I even forgot. Took down something.

23:59 KENNEDY: It was something major, yeah. I can't remember, but some major cloud provider went down because of it, yeah.

23:59 OKKEN: And how that could happen, so there's an interesting video talking about regular expression denial of service attacks and how it happens. It was just a interesting video. We'll have a link to it in the show notes if anybody wants to watch.

23:59 KENNEDY: Okay, yeah, yeah, that's super cool. So I got a couple I want to throw out there. 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 and you want to debug it, there's a new thing called httptoolkit, and it has special Python support. So this is a proxy you can run on your computer and say start recording, and it'll start recording all the requests that you're making. So it integrates with urllib.request, urllib2, requests, pip, Python 2 and 3, boto, all those things, and specifically catches traffic from those, and it does interesting stuff by changing the Python path and environment variables. And then all of these libraries that I talked about apparently respect certain proxy settings and things you can set, so it just auto, you don't have to change your app at all. You just start a terminal with httptoolkit and then run your code, and it can record it.

23:59 OKKEN: That's cool.

23:59 KENNEDY: Yeah, so if you're like, why is this crashing? You know, I run my request thing and then I get some kind of crash, and how am I supposed, you know, you don't have the developer tools in your web browser to look at the headers and whatnot, so you can do it with this. It's pretty cool. It's free, but there's also a paid version, just heads up. Also, there's a nice little link. Last time, the time before, Brian, we were talking about Magic, Python Magic, and you're like, well, that's a pretty strong name, to be magic, and all it does is detect file types, right? Remember that thing? So this, David Martinez sent over and 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. So, for example, if you had a SQLite file, it would start with 53514c69, et cetera. If you see those numbers up the front, that means SQLite, right?

23:59 MONTANI: So wait, do you actually know this by heart, or did you write this down?

23:59 KENNEDY: No, no. Oh, of course, yeah, I know that one, sure. No, I pulled it up. Let's see, really quickly, Python 3.74 is out. So I brew and upgraded my Python 3.7, which is how I did it on my machine, and it's already on homebrew, as well, so that was like, I don't know, six, seven hours delay there. It's really nice to see that come out real quick.

23:59 MONTANI: Or if you have pyenv, you can do pyenv, I don't even know the command, but like, install something, and...

23:59 KENNEDY: Right away happened, huh? That's awesome, yeah. And then the last one, I want to point out this thing called Flying, I'll just call it Flying Fractals. This person put together this project using pywonderland, and it automates some other libraries that are based on C. So they made some really cool videos of flying through three-dimensional animated Mandelbrot sets and other kind of stuff. And I just, when I was just watching, I thought just, wow, this is super cool computational stuff over here. I've done a bunch of work in complex dynamics and trying to visualize that and this kind of blew me away, so if you care at all about that stuff, I think you'll just enjoy a minute of that video.

23:59 MONTANI: Yeah, yeah. So yeah, actually, you might've actually noticed that my voice still isn't 100%, and it's a bit rough, and that's because last weekend, we had our very, very first conference here in Berlin called Spacy IRL. Like, you know, Spacy In Real Life. So our community came together, and I'm still absolutely blown away. There was, you know, the vibe was amazing. We had 200 people there in a lovely 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've already been released and, yeah, it'd be a bunch of, yeah, if you're interested in Natural Language Processing, Spacy, those, the talks are really, really great, and yeah, hope you enjoy watching them.

23:59 KENNEDY: Ines, also, I'm so glad you're putting them on YouTube, and wow, congratulations. 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 you could tell your voice was gone. It's great.

23:59 MONTANI: I know, that was like, yeah, wow. And it was also, it's actually quite refreshing to organize your own conference. We were like, okay, let's do all the things that we think a conference should do and try them out, and it actually worked quite well. 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 great. My voice suffered a bit but, you know, we're giving a lot back to the community, as in the videos, photos, stuff, so yeah.

23:59 KENNEDY: Yeah, sounds great. Awesome. Congratulations.

23:59 MONTANI: A couple of episodes ago, Brian actually talked about FastAPI, not to be confused with, 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 our APIs over. The exciting news here is that their co-developer, Sebastian Ramirez, is actually going to join our team here in Berlin. This means a lot of cool development for us, but also, we obviously, since we love the FastAPI project, we'll keep supporting that, and we'll definitely give him enough time to keep working on it.

23:59 OKKEN: That's great news.

23:59 MONTANI: We found him through the project. We saw, oh, he's doing some consulting work. We're like, hey, we'd love to work with him, and one thing came to another, and now, yeah, he'll be part of our Explosion team, which is still growing, by the way, so we've been very lucky that we could, we were able to work with more people and expand our team.

23:59 KENNEDY: Yeah, that's so cool that, yeah, that your business is growing. And I guess it's worth pointing out that, back on Talk Python To Me, we talked about Explosion AI. I interviewed you about building a software business. So back in episode 202. So this is just more evidence that that's all good advice. Yeah, super cool. Well, great, great news. I guess it's probably time for a joke here or two. A pyjoke, if you will, maybe. So I think this, I'll do the first one. This one I think came from pyjokes. We'll see. We're starting to run that well dry, so people, send in your jokes, please. But a programmer walks into the bar and orders 1.38 root beers. The bartender informs her that it's a root beer float. She says, "No, make it a double." All right, pretty bad type system. Maybe it doesn't work so well in Python. Like, we don't care so much about types. But, you know, still. So sorry.

23:59 OKKEN: I like it.

23:59 KENNEDY: All right, we have one more up here. Who put this one in, Brian?

23:59 OKKEN: 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. What do you call a developer without a side project?

23:59 KENNEDY: What's that?

23:59 OKKEN: Well-rested.

23:59 KENNEDY: Yeah, that's great. Totally true.

23:59 MONTANI: It's almost a bit sad in that sense.

23:59 KENNEDY: Yeah, Brian, that's just .

23:59 MONTANI: I know, it's too real. I personally actually was complaining.

23:59 KENNEDY: That's right.

23:59 MONTANI: But yeah, 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. You know, sleeping enough, stuff like that.

23:59 OKKEN: Oh, definitely, people should be, and I was, it's mostly a self-reflection.

23:59 MONTANI: No, I mean, it is a good joke. I'm not, I wasn't criticizing your joke. It's a totally fine joke. I'm just saying it's also, it's very real. You know how jokes can be too real, and then you're like, oh.

23:59 KENNEDY: Yeah, I'm really uncomfortable now. Exactly. All right, well, I think that's a good place to leave it. Brian, thank you, as always.

23:59 OKKEN: Thank you.

23:59 KENNEDY: Ines, it was great to have you here. Thanks for coming.

23:59 MONTANI: Yeah, thanks. Bye.

23:59 OKKEN: Bye.

23:59 KENNEDY: 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 If you have a news item you want featured, just visit 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. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page