Transcript #375: Pointing at Countries
Return to episode page view on github00:00 >> Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
00:05 This is Episode 375, recorded March 19th, 2024.
00:10 I think I got that right. I am Brian Okken.
00:13 >> I'm Michael Kennedy.
00:15 >> Our episode today is sponsored by Scout APM.
00:19 Thank you, Scout. Listen to their section later in the show.
00:22 If you'd like to connect to us, we're on Mastodon and the links are in the show notes,
00:27 but it's @mkennedy, @brianaukin, and @pythonbytes, all on fosstodon.org.
00:33 If you'd like to listen to this show live, we'd love to have you, but it's not necessary.
00:37 You can listen to us later.
00:38 But if you want to listen to us live, go to pythonbytes.fm/live and see all the details and see when the upcoming episode is.
00:47 Michael, what do you got for us?
00:50 >> Well, I would like to start off by telling you about another country,
00:54 maybe one you haven't heard of.
00:55 >> Canada?
00:56 >> You've heard of Canada, you've heard of the US, you've heard of Germany, you've heard of Slovakia,
01:00 you've heard of the Philippines.
01:02 Have you heard of Pi country?
01:04 >> Oh, this should have a song with it.
01:06 In a Pi country.
01:08 >> Does it involve a banjo?
01:12 I don't know what it's called.
01:13 >> I hope not.
01:14 >> I know. I hope not too.
01:16 >> We should have covered this on the 14th.
01:19 >> Pi country, Pi day, all the things.
01:21 So Pi country, it solves something that might not sound like a great big problem
01:26 until you try to deal with this and you're like, are you serious? There are this many things.
01:30 It's similar to dealing with time zones.
01:32 You're like, how complicated can be?
01:34 What are there, 24?
01:35 No. What are their abbreviations?
01:37 What are all the different ways in which they can be abbreviated and so on?
01:40 This is that for country.
01:41 So it's a Python library to access ISO.
01:44 These are standards, country, subdivision, what's a subdivision, language,
01:49 currency, and script definitions, and their translations for all the countries of the world,
01:54 including deleted countries that used to be countries but are not.
01:58 I would have considered those just former countries, but deleted is a very digital way to think of it.
02:03 We just selected that part and we hit command backslash and it really deletes it all the way.
02:11 Anyway, this is really interesting and it's used by 17.9 thousand different projects, which is pretty cool.
02:19 So here's the deal.
02:20 You go in here and somewhere, you can just go into it and you say, pycountry.countries and there's 249 here.
02:27 You get these, not just a list of strings, but you get rich objects back.
02:31 Like the first one is Afghanistan.
02:34 So country, it's a class.
02:36 It has the Alpha 2 code, which is AF, the Alpha 3 code, AFG, and that's the kind of stuff I'm talking about.
02:42 That's like, why are there so many variations?
02:44 You can represent the shorthand version like just two letters, but you can also use three letters or there's numeric versions.
02:51 There's like the full name versus the colloquial name.
02:54 So Afghanistan versus the Islamic Republic of Afghanistan.
02:58 >> Oh, this is cool. I might learn something.
03:00 >> Yeah, exactly. There's a lot more in here.
03:03 It has a dictionary-like access for the variation.
03:07 So you can say, get Alpha 2 equals DE and you'll get good old Deutschland,
03:12 or you could say Alpha 3 equals DEU or the name equals Germany or all these different ways in
03:20 which you can query this or given one, you can obviously just access all these properties.
03:25 Like Brian, you would know that it's the Federal Republic of Germany.
03:29 It has fuzzy searching for country.
03:31 So I can say, give me England.
03:32 It's like, yeah, there's no England.
03:33 What? But there's this thing called United Kingdom, which has its center in England maybe,
03:38 and that's GB and so on.
03:41 So yeah, pretty neat.
03:42 You can say fuzzy search for Cote and you get Cote d'Ivoire.
03:47 Sorry, folks, from there, but it'll even match when it's not exactly the right character.
03:56 Oh, hat, I don't know what that's called.
03:58 Not an umlaut, but a hat-looking thing.
04:00 But you don't have that in the search.
04:02 So this is more, like I said, there's more to this than just a list of countries.
04:06 Then it's historic countries.
04:09 These are the ones. Since I read this, did they change it from historic to deleted?
04:12 I don't know. Historic countries, subdivisions.
04:15 Like what is a subdivision of a country?
04:17 This is like states or providences.
04:20 It's not nearly as strange as it sounds.
04:22 There's scripts also. What is a script?
04:24 It's written language versus spoken language.
04:27 Those might be the same thing, but they might also not be the same, like Latin, for example, right?
04:32 Oh, yeah.
04:33 Currencies are in here.
04:35 Languages are in here.
04:36 Locales are in here.
04:38 So if you do anything with countries, this might be worth looking at.
04:41 That's pretty cool.
04:42 Yeah.
04:43 It's still like hung up on the England isn't a country, but okay.
04:46 According to Pi country, it's not a country.
04:50 Okay.
04:50 And also, so yeah, I'll have to look into this more.
04:54 Is it a subdivision?
04:55 Maybe it's a subdivision.
04:56 And, but also like, where does the word Deutschland fit in for Germany?
05:02 Is that not even listed?
05:04 Yeah. Well, also since it has translations.
05:07 So for example, German, if you ask a German person where they're from, they'll say Deutschland,
05:12 unless they're speaking English to people, right?
05:13 Like they refer to it as Deutschland.
05:15 Yeah.
05:16 But for some reason, we don't agree.
05:17 We don't call it that.
05:18 We call it Germany, right?
05:21 So I don't know.
05:22 It's interesting.
05:23 I suspect if you use the translations maybe, and you said, you know, what is the name,
05:27 the official name of Germany?
05:29 It probably wouldn't say the Federal Republic of Germany.
05:31 We have that translated, right?
05:34 Interesting.
05:35 Yeah.
05:36 Like Switzerland is, Sveits?
05:39 I can't remember exactly, but yeah, it's different.
05:41 It goes by different names in different languages.
05:44 So I think it also has those when it talks about the translations.
05:48 Cool, neat.
05:49 Well, we could point to countries.
05:52 I'm trying to do a transition.
05:54 Or we could point to objects.
05:56 And does Python have pointers?
06:00 You can't really point to a country.
06:01 I don't know.
06:02 Maybe.
06:03 Point to directions.
06:04 Canada's that way.
06:07 Canada's that way?
06:08 No, Canada's this way.
06:10 Oh man.
06:11 But we're probably pointing to different directions.
06:14 Anyway.
06:15 So Ned Batchelder has an article called, does Python have pointers?
06:19 And I'm like, yeah, no, it doesn't.
06:22 But kind of does.
06:24 Anyway, I'm highlighting this because I think it's a really good article
06:28 for somebody that's coming from a language that does have pointers and stuff to Python
06:35 because it's a good entry way into names in Python.
06:38 So the article does Python have pointers, but it's kind of pointing to the idea
06:45 of like talking about the ID function.
06:48 And I know about the ID function really well.
06:52 So if you say ID of an object or a variable name, it tells you like a number for what it points to.
07:01 Like where the, I don't know, it's a representation of the memory address or something.
07:05 That's kind of what a pointer is, right?
07:07 But you can't in C and C++ and Rust and other things, you can dereference it.
07:11 Using that, you can create a variable.
07:14 Using the address, you can create a variable that points to that thing.
07:17 And you cannot do that within Python.
07:19 So it is different, but also kind of everything is a pointer in Python.
07:24 And that's sort of Ned's point is, point, pointer, is that with like just normal object,
07:32 we can say like my var equals 17, and then we can have, if you do my pointer, it doesn't help you any.
07:40 But you can do another variable that points to the same thing and it works.
07:46 It's when, it's just sort of how names work.
07:49 I'm describing this very poorly, but this is a good entry point into, well, how objects work.
07:55 And luckily, Ned also links to a talk he did, names that refer to objects.
08:00 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,
08:08 it's really good to understand just really how names work.
08:12 We're just, in Python, we just kind of point to things.
08:14 And so I'm gonna link, we're gonna link also to the 2015 article, Python Names and Values.
08:21 And really, this was the trick.
08:24 When I really could grok this thing with Python, then I could understand Python.
08:30 Everything else seems easy after this.
08:32 So good job, Ned.
08:34 - Yeah, Ned always has good writing.
08:36 I'm subscribed to his RSS feed.
08:38 I think it's interesting to consider whether Python, you know, the article, does Python have pointers?
08:43 Like, boy, howdy, does it?
08:44 (both laughing)
08:45 - Yeah, yeah.
08:46 - Like, it has more pointers than C++, which is insane.
08:50 It doesn't have a wider variety of ways to like dereference them, you know, as stars,
08:55 like casting a void star, star to something else.
08:57 But everything, literally everything in Python is a pointer.
09:00 Even numbers are pointers.
09:02 Whereas in C++, numbers usually are value types, right?
09:06 And you can have stuff that's on the stack that's not a pointer, just has the value.
09:09 In Python, there is no way to have just a value.
09:12 Every, everything is a pointer, often pointers to pointer.
09:15 You know, you're traversing something to something, right?
09:17 It's like, I'm going to find the dictionary of the class, and then I'm following that to where it points to
09:23 to get to the value.
09:24 So it's worth spending some time on, even though you don't ever see a star
09:30 or an ampersand in the context of like juggling pointers in Python.
09:34 - Yeah, and like vectors or lists in Python are not, they're not the start of a chunk of memory
09:42 that represents all of your items.
09:43 That's not what's going on.
09:45 It's something completely different.
09:47 Forget that.
09:48 So, yeah.
09:49 - Indeed, indeed.
09:51 Very good, very good.
09:52 - Well, changing gears a little bit, we'd like to thank Scout APM for sponsoring this episode.
09:58 - Yes, we would.
10:00 Let me tell you real quick about Scout APM.
10:04 They're big supporters of Python Bytes, so we appreciate that very much.
10:07 So if you are tired of spending hours trying to find the root cause of issues
10:12 impacting your performance, then you owe it to yourself to check out Scout APM.
10:16 They're a leading Python application performance monitoring tool, APM, that helps you identify and solve performance abnormalities
10:24 faster and easier.
10:26 Scout APM ties bottlenecks such as memory leaks, slow database queries, background jobs,
10:31 and the dreaded N+1 queries that you can end up if you do lazy loading in your ORM,
10:36 and then you say, "Oh no, why is it so slow?
10:39 "Why are you doing 200 database queries "for what should be one?" So you can find out things like that.
10:43 And it links it back directly to source code, so you can spend less time in the debugger
10:47 and healing logs and just finding the problems and moving on.
10:50 And you'll love it because it's built for developers by developers.
10:53 It makes it easy to get set up.
10:55 Seriously, you can do it in less than four minutes, so that's awesome.
10:58 And the best part is the pricing is straightforward.
11:02 You only pay for the data that you use with no hidden overage fees or per seat pricing.
11:07 And I just learned this, Brian, they also have, they provide the pro version
11:12 for free to all open source projects.
11:14 So if you're an open source maintainer and you want to have Scout APM for that project,
11:19 just shoot them a message or something on their pricing page about that.
11:22 So you can start your free trial and get instant insights today.
11:26 Visit pythonbytes.fm/scout.
11:28 The link is in your podcast player show notes as well.
11:31 And please use that link.
11:32 Don't just search for them because otherwise they don't think you came from us.
11:36 And then they'd stop supporting the show.
11:37 So please use our link pythonbytes.fm/scout.
11:40 Check them out.
11:41 It really supports the show.
11:43 - Yes, it does.
11:44 - Thank you.
11:45 It does, it sure does.
11:45 Now, Brian, let's talk about ingestion, data ingestion.
11:50 - Okay.
11:51 So here's that open source CLI tool.
11:54 It's not exactly Python focused, but certainly useful for Python people.
11:59 Ingestor, and it's straight out of the web 2.0 days 'cause it's dropping some of the vowels.
12:05 It says copy data between any source and any destination thinking database type things.
12:12 So what you do is you just say ingestor, ingest.
12:15 Source database connection is whatever.
12:18 Source table is whatever.
12:20 And then the destination is where it goes.
12:23 And all of a sudden now you have that.
12:24 So do you want your Postgres data to appear over in BigQuery?
12:29 Do you want your MongoDB collection to show up in Postgres?
12:33 One CLI command done.
12:35 - Oh, that's pretty cool.
12:36 - It's pretty cool, right?
12:37 - Yeah.
12:38 - So it's a command line application that allows ingesting or copying data from any source into any database.
12:45 I mean, this guy probably should be a star on any.
12:50 How about many, many data sources?
12:52 - Okay, yeah.
12:53 - Yeah, so if we jump over here to their docs where like their homepage is kind of just
12:59 to catch your interest.
13:01 So you can copy, I'll find the sources and tell you about them in a second.
13:03 But it says there's three ways to copy stuff over.
13:07 You can do an append, which is kind of cool.
13:09 Like if you've got multiple data sources that are localized saving of data
13:14 and you want to put them all into one place.
13:17 Like if you had a bunch of SQLite files from different locations, say you've got a bunch of,
13:23 I don't know, a bunch of IoT things, or you got a bunch of servers and they each keep some data in a SQLite file
13:30 and you want to put that into one big database, right?
13:33 You could do append.
13:34 Or you could say merge.
13:35 I'm guessing if the primary key is the same, it just skips it, maybe it doesn't update to that thing
13:40 if the fields are different, I don't know.
13:42 Or you can just wipe it free and insert.
13:45 So like a clean replacement, delete and insert.
13:49 - Yeah. - Yeah, pretty cool.
13:50 And then somewhere down here, supported sources.
13:53 Here's where I was joking about the any.
13:54 Supports Postgres and it has, some of them are bidirectional source or destination.
13:59 Some are just source, some are just destination.
14:01 Postgres, BigQuery, Snowflake, Redshift, Databricks, DiffDB, Microsoft SQL Server,
14:05 and CSV files are all bidirectional.
14:08 CSV files are bidirectional, okay?
14:10 But Mongo, Oracle, SQLite, and MySQL are only sources.
14:15 So I don't know why MongoDB is not a destination 'cause it's incredibly easy to just have like a flat file,
14:21 a flat table, no like nested stuff.
14:24 I know if you're copying from a relational database, but yeah, whatever.
14:27 Still pretty cool, I think, to be able to use this.
14:30 So if you got just data you wanna keep in sync or migrate over, you're thinking of writing Python code
14:34 to do it, you might not have to write any code at all.
14:36 - Well, that's pretty cool.
14:37 I don't know what Snowflake is.
14:39 It's a great name.
14:39 - Yeah, we're getting out of that season right now.
14:41 It's starting to be warm and summer's coming, but it'll be back in the fall, like maybe December.
14:46 No.
14:47 - That's funny, cool.
14:48 Well, yeah, very interesting.
14:50 Speaking of command lines, I ran across David Lord's article, "Make your terminal nice."
14:56 And this is just sort of a little shout out because so apparently David is using,
15:02 he's using Phish, which I haven't heard about for a while.
15:06 So a nicer prompt with Starship and a nicer shell with Phish.
15:10 And this isn't really a detailed article, but it's just sort of like things can be nicer.
15:16 And I was reminded about this because I think a long time ago we were talking with,
15:21 anyway, somebody else about Starship.
15:25 And I was like, I should try Starship.
15:28 And I tried it and for some reason it didn't work for me.
15:31 But I'm like, this, I think it's time to start again.
15:33 And so I looked into both of these.
15:36 I tried Phish and I do really appreciate that it says finally a command line shell for the 90s,
15:42 which is awesome and funny.
15:45 And it's also in Comic Sans, which I ironically appreciate.
15:50 But the scripting language is a little different and I've got a lot of customizations for Bash
15:56 and Z Shell is very compatible with Bash.
15:59 So I usually use either Bash or Z Shell.
16:02 And I think I'm gonna stick with that.
16:04 But Starship, Starship's amazing.
16:07 And so I switched to Starship and the, when you go to Starship, there's an installation guide
16:13 and really it was so easy.
16:15 It was, there's a macOS line.
16:18 You just curl install it or you can homebrew.
16:22 Think I did the homebrew thing.
16:23 Anyway, but then how do you use it?
16:26 There's a usage of just, so I was on Z Shell.
16:30 So you just had to add one line to your Z Shell RC, but there's instructions on how to do it within Bash
16:37 or Phish or PowerShell or, oh cool, it works with PowerShell, that's pretty neat.
16:43 For all you Windows people out there.
16:45 But so what you get, what I really like is this notion of the directory is right there listed above your command.
16:55 And then listing what I really like is what my get branch is my directory, which version of Python I'm using.
17:05 The example here shows a rust, but it shows which version of Python you're using.
17:10 And then also what virtual environment you're in.
17:12 So having, and I didn't configure that at all.
17:15 That's just the default.
17:16 Then I'm like, that's good.
17:17 I'm good with that.
17:19 So I haven't configured it at all.
17:20 Just the default right out of the box.
17:22 It works really good.
17:23 So I'm pretty happy so far.
17:25 Anyway. - Nice.
17:26 Yeah, I think there's a lot of options here, right?
17:28 There's on my Z Shell, there's Starship.
17:31 There's all the different shells.
17:33 These days I'm using warp, warp.dev, which is pretty excellent.
17:36 I talked about that on the show before.
17:38 - I kind of forgot about warp.
17:39 We should try it.
17:39 - Yeah, warp is cool.
17:41 I think the big thing, the big message people should take away from this is,
17:45 don't just take what your operating system gives you.
17:48 It's really quite bad.
17:50 It's not just not great, it's bad.
17:53 And a lot of people who are like, I don't really like, I'm not really a terminal person,
17:58 or I'm not a CLI person.
18:00 Like that's because they didn't spend 30 minutes once getting into it.
18:05 Like, oh, actually, oh, that's nice.
18:06 And like you pointed out, like, oh, well, is there a virtual environment active?
18:09 What is its version?
18:11 And then all these other things, are there Git changes?
18:13 Am I in a Git repository at all?
18:14 Are there changes, et cetera?
18:16 Like all those little, every one of those is just, oh, that's nice too.
18:19 And it really adds up.
18:21 - Well, and I've always been one to, I mean, for my career, usually juggling multiple projects,
18:28 multiple branches on projects and everything.
18:32 And I've kind of been okay knowing what I'm doing.
18:35 However, recently I just have leveled up that of using way more branches, way more projects,
18:43 and just having that information for me right there to make sure that I know what version of Python I'm using,
18:49 what branch I'm on.
18:50 And having that just ever present is like, oh my God, I don't have to think about that anymore.
18:55 Awesome, it's just right there.
18:56 So I just hit that pain point where having that information is helping me.
19:01 And so I appreciate it.
19:03 So yeah. - Very nice.
19:04 - Cool. - Very nice.
19:06 - How about any extras?
19:07 Do you have any extras for us?
19:08 - I'm feeling extra today.
19:09 I got a few extras for folks.
19:11 First of all, I spoke about UV, or no, Brian, you spoke about UV and I just jumped on.
19:15 We both wanted to talk about it, but you had it first, I believe.
19:18 - Yeah.
19:19 - So it was officially your topic on the show.
19:20 However, and you had Charlie Marsh on Testing Code.
19:25 And so I just published an episode of Talk Python, having a conversation with Charlie about UV
19:32 and a little bit of rough and just life in general.
19:34 But I have a big backlog of shows over there that I'm working to release
19:39 'cause I've recorded faster than weekly release cadence.
19:43 But this one seemed very timely.
19:45 So I put it to the front of the queue so people can check that out.
19:48 - I can't wait to listen to.
19:50 - Yeah, it was fun.
19:51 Also follow up here is there's this really interesting YouTube channel.
19:56 I don't know if it's in general interesting, just the one I watched is called Dark Matter.
20:01 And they have like highly produced video versions of what would be a podcast,
20:08 which is kind of interesting.
20:10 So they had the one with David DHH talking about the Leaving the Cloud, Cloud Fusion.
20:15 But just like, if you look at the video side of it, it's like, could be a documentary sort of thing.
20:20 So anyway, that's interesting.
20:21 We're checking out.
20:22 You wanna follow up on all my Leaving the Cloud talk I did.
20:25 For those who like to live out near the front of the leading edge, Python 3.13 Alpha 5 is available
20:34 and people can go check that out.
20:36 So it's not quite beta.
20:38 And once it hits beta, there's no more changes, but right now there's still potentially breaking changes.
20:43 Things could be added, things could be removed, so on.
20:45 But in this thing I'm linking to, there's a nice list of what's some of the improvements.
20:49 Like for example, how exciting a preliminary experimental JIT was added,
20:53 by the way, just like throwing that out there as if it's nothing.
20:56 Your Python will be compiled.
20:59 And then finally, this one comes to us from Pat Decker, Target Tech.
21:04 So the tech blog at Target.
21:06 This is really cool.
21:07 Said, "Target posted something on their blog," which I didn't know they had a tech blog,
21:12 so that's I guess news, but cool for them.
21:15 "Announcing Target's open source fund." - Oh, cool. - Yeah.
21:18 And it says, "We created Target's open source fund "as a commitment to support open source projects we use.
21:22 "In short, Target now directly donates to projects "through an internal process that prioritizes
21:28 "representation of Target's technology team." Perfect, this is perfect.
21:32 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
21:40 and Microsoft's open source funds have inspired them to go further.
21:45 And then it lists projects like, you just gave a shout out to Homebrew, open API generator, SDK man,
21:50 MockK for Kotlin and HTTP 4K.
21:55 So it looks like they do a lot of stuff with Kotlin.
21:58 So they're supporting that, but whatever, right?
22:00 You support what you use.
22:01 I think that's cool.
22:02 - Yeah, I think, yeah, every company.
22:04 I mean, every big company, even companies you don't even think use open source
22:08 use open source, so.
22:10 - Yes, exactly.
22:11 Yeah, there was a quote they gave in here that said, "The Linux Foundation estimates that 90% of the code
22:16 "in production is of open source origin." Probably using libraries based on open source,
22:22 I would imagine.
22:23 The fact you use Flask would make your stuff of open source origin, I would imagine.
22:27 - Yeah, and I know that there are some wrinkles in how the money often gets distributed,
22:33 but some money getting distributed is better than none.
22:36 So that's a good thing.
22:37 - I'll say one more thing just to encourage other companies, people within other companies to do this.
22:42 We recognize that it's our responsibility to engage across a broad spectrum of activities.
22:47 This includes contributing our own software to open source, joining communities and patching software used by others,
22:52 plus funding with money the others they mentioned.
22:55 That's pretty cool.
22:56 - Yeah, cool.
22:58 Well, the only extra I've got is that I have been working on a side project that I'm starting to ramp up a little bit,
23:05 and I've decided to have a start in a SaaS project.
23:10 And I've started, thought I would get a little headstart by using Corey Zhu's SaaS Pegasus.
23:18 So I talked with him just the other day.
23:21 So his interview will be on Python test.
23:25 But as I go along, I'll be reporting how it's going.
23:30 And yeah, I'm just excited to get started.
23:33 - Nice, you're gonna live blog it, blog the progress.
23:36 - Yeah, it's just gonna be slow going 'cause there's a lot more going on in my life,
23:42 but I wanna get it off the ground.
23:44 - Indeed.
23:45 I know the feeling.
23:47 - How about something funny?
23:49 - Yes, let's talk about something funny.
23:50 So this comes to us from DevHumor, directly submitted by admin.
23:54 It's got like a kind of a cybersecurity thing here, Brian.
23:58 So like social engineering, like, hey, I'm from IT, you're gonna get a pop-up on your authenticator
24:04 that says, we're just checking some systems.
24:07 So if you don't mind just approving that.
24:10 I know it's your personal email, but we're just working on it for you.
24:13 So anyway, here's the joke.
24:15 If a person who tries to trick others into giving them personal or sensitive information
24:20 is a social engineer, does that mean that the person who tries to prevent that is an anti-social engineer?
24:26 - Well, I mean, I've met a lot of cybersecurity people and I, maybe. (laughs)
24:33 I think it might be an overgeneralization, but yeah.
24:37 - Yeah, it's funny.
24:38 Anyway, are you an anti-social engineer?
24:40 This time it's a good thing.
24:42 - I know just who I need to send this to.
24:45 This is awesome.
24:46 - Perfect.
24:47 - Awesome, thanks.
24:49 Well, that was a fun episode and thank you everybody for listening and watching
24:53 and everything and thank you, Michael.
24:55 - Yep, you bet.