- Podcasts
- Python Bytes
- #375 Pointing at Countries
About this episodeTopics covered in this episode: pycountry Does Python have pointers? ingestr Make your terminal nice Extras Joke See the full show notes…
See the full show notes for this episode on the website at pythonbytes.fm/375
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#375 Pointing at Countries
There are this many things. It's similar to dealing with time zones. You're like, how complicated it can be? What are there, 24? No. And what are their abbreviations? And what are all the different ways in which they can be abbreviated and so on? This is that for countries. So, it's a Python library to access ISO.
These are standards. Country, subdivision. What's a subdivision? Language, currency, and script definitions and their translations for all the countries of the world, including deleted countries that used to be countries but are not. I would have considered those just former countries, but deleted is a very digital way to think of it.
We just selected that part and we hit, you know, command backslash and it really deletes it all the way. Yeah. Anyway, this is really interesting and it's used by 17.9 thousand different projects, which is pretty cool. So, here's the deal. So, you go in here and somewhere, you can just go into it and you say pi country.countries and there's 249 here.
And you get these, not just a list of strings, but you get rich objects back. Like, the first one is Afghanistan. So, country, it's a class. It has the alpha two code, which is AF, the alpha three code, AFG. And that's the kind of stuff I'm talking about. That's like, why are there so many variations?
You can represent, you know, the shorthand version, like just two letters, but you can also use three letters or there's numeric versions. There's like the full name versus the colloquial name. So, Afghanistan versus the Islamic Republic of Afghanistan. Oh, this is kind of cool. I might learn something.
Yeah, exactly. There's a lot more in here. And there, it has a dictionary-like access for the variation. So, you can say, get alpha two equals DE and you'll get good old Deutschland. Or you could say alpha three equals DEU or the name equals Germany or all these different ways in which you can kind of query this.
Or given one, you can obviously just access all these properties. Like, Brian, you would know that it's the Federal Republic of Germany. It has fuzzy searching for countries. So, I can say, give me England. It's like, yeah, there's no England. What? But there's this thing called United Kingdom, which sort of has its center in England, maybe.
Not an umlau, but a hat-looking thing. But you don't have that in the search, right? Yeah. So, this is more, like I said, there's more to this than just like, oh, a list of countries. And then, it's historic countries. These are the ones. Did they, since I read this, did they change it from historic to deleted?
I don't know. Historic countries. Subdivisions. I'm like, what is a subdivision? Of a country. This is like states or providences. It's not nearly as strange as it sounds. There's scripts also. What is a script? It's written language versus spoken language. Those might be the same thing, but they might also not be the same.
So, I don't know. It's interesting. I suspect if you use the translations, maybe, and you said, you know, what is the official name of Germany? It probably wouldn't say the Federal Republic of Germany would have that translated, right? Interesting. Yeah. Like, Switzerland is, I can't remember exactly.
You can't really point to a country. I don't know. Maybe. Point to directions. Canada's that way. Canada's that way. No, Canada's this way. Oh, man. But we're probably pointing to different directions. Anyway. So, Ned Batchelder has an article called, Does Python have pointers? And I'm like, yeah, no, it doesn't.
But kind of does. Anyway. I'm highlighting this because I think it's a really good article for somebody that's coming from a language that does have pointers and stuff to Python. Because it's a good entryway into names in Python. So, the article does Python and pointers. But it's kind of pointing to the idea of, like, talking about the ID function.
And I know about the ID function really well. So, if you say ID of an object or a variable name, it tells you, like, a number for what it points to. Like, where the, I don't know, it's a representation of the memory address or something. That's kind of what a pointer is, right? But you can't, in C and C++ and Rust and other things, you can dereference it.
Using that, you can create a variable. Using the address, you can create a variable that points to that thing. And you cannot do that within Python. So, it is different. But also, kind of everything is a pointer in Python. And that's sort of Ned's point, is that with, like, just normal object, we can say, like, my var equals 17.
And luckily, Ned also links to a talk he did, names that refer to objects. And so, he did a talk in 2015, and still the slides are up in the video, but even the slides just going through it. It's really good to understand just really how names work. We're just, in Python, we just kind of point to things.
You know, it starts, like, casting a void star star to something else. But everything, literally everything in Python is a pointer. Even numbers are pointers. Whereas in C++, numbers usually are value types. Yeah. Right. And you can have stuff that's on the stack that's not a pointer, just has the value.
That's not what's going on. It's something completely different. Forget that. So, yeah. Indeed, indeed. Very good. Very good. Well, changing gears a little bit, we'd like to thank Scout APM for sponsoring this episode. Yes, we would. Let me tell you real quick about Scout APM. They're big supporters of Python Bytes, so we appreciate that very much.
So if you are tired of spending hours trying to find the root cause of issues impacting your performance, then you owe it to yourself to check out Scout APM. They're a leading Python application performance monitoring tool, APM, that helps you identify and solve performance abnormalities faster and easier.
Seriously, you can do it in less than four minutes. So that's awesome. And the best part is the pricing is straightforward. You only pay for the data that you use with no hidden overage fees or per seat pricing. And I just learned this, Brian. They also have, they provide the pro version for free to all open source projects.
So if you're an open source maintainer and you want to have Scout APM for that project, just shoot them a message or something on their pricing page about that. So you can start your free trial and get instant insights today. Visit buythombice.fm slash Scout. The link is in your podcast player show notes as well.
Now, Brian, let's talk about ingestion, data ingestion. Okay. So here's an open source CLI tool. It's not exactly Python focused, but certainly useful for Python people. Ingestor. And it's straight out of the web 2.0 days because it's dropping some of the vowels. It says copy data between any source and any destination thinking database type things.
So what you do is you just say ingestor ingest. Source database connection is whatever. Source table is whatever. And then the destination is where it goes. And all of a sudden, now you have that. So do you want your Postgres data to appear over in BigQuery? Do you want your MongoDB collection to show up in Postgres?
Some are just source. Some are just destination. Postgres, BigQuery, Snowflake, Redshift, Databricks, DIPDB, Microsoft SQL Server, and CSV files are all bidirectional. CSV files are bidirectional, okay? But Mongo, Oracle, SQLite, and MySQL are only sources. So I don't know why MongoDB is not a destination because it's incredibly easy to just have like a flat file, a flat table, no like nested stuff.
Well, that's pretty cool. I don't know what Snowflake is. It's a great name. Yeah, we're getting out of that season right now. It's starting to be warm and summer's coming, but it'll be back in the fall, like maybe December. No. That's funny. Cool. Well, yeah, very interesting. Speaking of command lines, I ran across David Lord's article, Make Your Terminal Nice.
And this is just sort of a little shout out because so apparently David is using he's using fish, which I haven't heard about for a while. So nicer prompt with starship. So nicer prompt with starship and a nicer shell with fish. And this isn't really a detailed article, but it's just sort of like things can be nicer.
And I was reminded about this because I think a long time ago we were talking with. Anyway, somebody else about starship. And I was like, I should try starship. And I tried it. And for some reason, didn't work for me. But I'm like this. I think it's time to start again. And so I looked into both of these.
Oh, cool. It works with PowerShell. That's pretty neat for all you Windows people out there. So what you get, what I really like is this notion of the directory is right there listed above your command. And then listing what I really like is what my Git branch is, my directory, which version of Python I'm using.
What is its version? And then all these other things, you know, are there Git changes? Am I in a Git repository at all? Are there changes? Et cetera. Like all those little, every one of those is just, oh, that's nice too. And, you know, it really adds up. Well, and I've always been one to, I mean, for my career, I'm usually juggling multiple projects, multiple branches on projects and everything.
And I've kind of been okay knowing what I'm doing. However, recently, I just have leveled up that of using way more branches, way more projects. And just having that information for me right there to make sure that I know what version of Python I'm using, what branch I'm on. And having that just ever present is like, oh, my God, I don't have to think about that anymore.
First of all, I spoke about uv or no, Brian, you spoke about uv and I just jumped on. We both wanted to talk about it, but you had it first, I believe. Yeah. It was officially your topic on the show. However, and you had Charlie Marsh on testing code. And so I just published an episode of Talk Python having a conversation with Charlie about uv and a little bit of rough and just life in general.
Also follow up here is there's this really interesting YouTube channel. I don't know if it's in general interesting. Just the one I watched is called Dark Matter. And they have like highly produced video versions of what would be a podcast, which is kind of interesting. So they had the one with David DHH talking about the leaving the cloud, cloud fugitive.
But just like if you look at the video side of it, it's like could be a documentary sort of thing. So anyway, that's interesting. And we're checking out. You want to follow up on all my leaving the cloud talk I did. For those who like to live out near the front of the leading edge, Python 3.13 alpha 5 is available.
And people can go check that out. So it's not quite beta. And once it hits beta, there's no more changes. But right now, they're still potentially breaking changes. Things could be added. Things could be removed. So on. But in this thing I'm linking to, there's a nice list of, you know, what's some of the improvements like.
In short, Target now directly donates the projects through an internal process that prioritizes representation of Target's technology team. Perfect. This is perfect. Like, it says, look, we're basing this on some of the prior work that's out there. And in fact, the success of Sentry and Microsoft's open source funds have inspired them to go further.
Probably, you know, using libraries based on open source. I would imagine, you know, like the fact you use Flask would make your stuff of open source origin, I would imagine. Yeah. And I know that there are some wrinkles in how the money often gets distributed, but some money getting distributed is better than none.
So that's a good thing. I'll say one more thing just to encourage other companies, people within other companies to do this. We recognize that it's our responsibility to engage across a broad spectrum of activities. This includes contributing our own software to open source, joining communities and patching software used by others, plus funding with money the others.
So I'm, I talked with him just the other day. So his interview will be on, on, on Python test. But as I go along, I'll be reporting how it's going. And yeah, I'm just excited to get started. So nice. You're going to live blog it, blog, blog the progress. Yeah. It's just, it's just going to be slow going because there's a lot, there's a lot more going on in my life, but I want to get it off the ground.
You're going to get a pop-up on your authenticator that says, you need this. We're just checking some systems. So if you don't mind just approving that, you know what I mean? I know it's your personal email, but we're just working on it for you. So anyway, here's the joke. If a person who tries to trick others into giving them personal or sensitive information is a social engineer, does that mean that the person who tries to prevent that is an anti-social engineer?
