#243: Python on Windows is OK, actually Transcript
00:00 We all love the Python language, but it's the 200,000 plus packages that actually make Python
00:05 incredibly useful and productive. But installing these packages and even installing Python itself
00:11 can vary across the different platforms. In particular, Windows has had a hard time.
00:17 Many of the library authors don't use Windows, and so they don't test their packages on that
00:22 platform. Tutorial authors often start their tutorial steps by activating a virtual environment.
00:28 That's great. That's the great first step, but it is usually source venv slash bin slash activate,
00:34 and that doesn't work on Windows. Yet over 50% of all developers programming in Python do so on
00:41 Windows. In this episode, we'll welcome back Steve Dauer. He works at Microsoft and is a Python core
00:47 developer. He has a bunch of statistics around Python and Windows for us. He also has tons of
00:52 good news on how Python and Windows is getting much better. This is Talk Python to Me, episode
00:58 243, recorded on location at Microsoft Ignite in Orlando, Florida, November 8th, 2019.
01:04 Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem,
01:22 and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm at,
01:27 mkennedy. Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on
01:32 Twitter via at talkpython. Hey everyone, Michael here. I'm excited to tell you about our latest course.
01:38 Yes, we just released one a week or two ago, but here's another. This time, it's a nine-hour course
01:43 called Python for the .NET Developer. The idea is, if you have experience with C Sharp and .NET,
01:49 would like to get better at Python, we'll take a bunch of common applications from the .NET space
01:54 and recreate them in Python. For example, we'll take a data-driven web app in ASP.NET and Entity
02:00 Framework and recreate that in Flask and SQLAlchemy. This means you can take all the concepts and ideas
02:05 that you know if you're a .NET developer and quickly transition to being an effective Python
02:10 developer. Are you the sole Python developer at a .NET shop? Maybe your team or co-workers could quickly
02:15 use their .NET background to get up to speed on Python to make it an important part of your tech stack.
02:20 There's even a For My Team button. Just click that and enter the number of team members you have,
02:25 and you'll probably get a discount to boot. I was also just a guest on the excellent .NET
02:29 Rocks podcast with Carl Franklin and Richard Campbell. If the idea of the Python for .NET
02:34 developer course intrigues you, just visit .NET Rocks.com? show equals 1665 to hear us discuss this from
02:42 both sides of the technology fence. So check out the course at hawkpython.fm slash .NET, D-O-T-N-E-T,
02:50 and convert those C-sharp skills to Python skills. Now, let's go talk with Steve.
02:55 Steve, welcome back to Talk Python to Me. Thanks for having me back. It's great to have you here.
02:59 We're recording on location here at Microsoft Ignite, so a lot of fun to do that at the conference
03:05 here. Yeah, is this your first time at Ignite? It is my first time at Ignite. How have you found it?
03:10 I've been a couple of times. I am very surprised at this place, to be honest. So to me, big conferences
03:16 are PyCon, Microsoft Build is a pretty big conference. This thing is like six times,
03:24 seven times as large as those. The scale is crazy. This is 30,000 attendees, at least on the first day.
03:29 I feel like it drops off. I don't think there's 30,000 today. We're on the last day. It's kind of
03:34 quiet. Yeah, it's way, way more quiet. But yeah, I actually found it really nice. I've made a lot of
03:39 cool connections and met a lot of people. I've met a lot of Python people even here running to some
03:44 folks. So I'm finding it to be a cool event. He had an interesting person come up and ask you about
03:49 your laptop. Oh, yeah, yeah. So it is the mix of the audience. It's not really a developer crowd,
03:54 right? It is sometimes, it is a developer crowd, but it's also an IT crowd. It's a SharePoint crowd.
04:01 It's a DevOps crowd. It's a cloud person. There's like all these different,
04:04 like all the computing IT folks brought together. So I was sitting around actually getting ready for
04:09 this interview to talk to you. I was taking some notes about what we're going to talk about. And
04:13 this guy comes up next to me. He's like, hey, that's a cool Surface book you got there. I don't
04:17 think I've seen that one before. I'm like, it's really cool, but it's a Mac book, not a Surface
04:22 book or Surface laptop or whatever he called it. So yeah, it's just, it's really funny. And I think that
04:27 actually is, it's an interesting angle to what we're going to talk about today.
04:31 Yeah, it's such a different crowd here compared to the Python conferences where we'd normally hang
04:36 out. I feel like, I feel like I've invited you into my house for this one.
04:39 Yeah, I've come to visit you this time, not the other way around. That's right. So yeah, I think
04:43 at PyCon, non-Windows computing or development is pretty common. And here, like, no joke,
04:52 they were mistaking my Mac for a Windows machine and like, oh, well, I only do C Sharp. I'm like,
04:57 okay, that's cool. Yeah, I know C Sharp too, but now I'm doing Python over here right now,
05:01 you know, things like that. And it's cool to be part of these different communities.
05:05 And it has been really exciting to see the change at Ignite over the years and Build, in fact,
05:09 because they are very different communities. But the growing Python that's showing up in them,
05:14 I feel like the first or second time I was at Build and Ignite, which would have been
05:19 2014 or so, about five years ago, people were asking, you know, what's Python? Why are you here?
05:25 Which is, you know...
05:28 What are you doing at our conference? Why did you invade it with your open source weirdness?
05:31 Right, exactly. It's like, what's your angle here? And they were kind of suspicious. And now it's at
05:36 the point where I actually had someone come up to me yesterday and say, you know, because I was here,
05:42 because I was actually here and saw everything going on, I now want to learn Python.
05:47 And that, I mean, I've never heard of that happening at the Microsoft conferences before,
05:52 but that's really exciting.
05:53 It's super exciting. Yeah, it is exciting. You know, I don't know, maybe they saw some kind of
05:58 machine learning presentation or something. They're like, wow, that I thought this was a
06:03 scripting language. Look what they're doing.
06:04 Yeah, we had a lot this year. I think two years ago, I was the only Python presentation at the entire
06:09 conference, which was...
06:11 There's a lot of presentations at this. That's like a very small percentage, right?
06:14 There's like, I don't know, we have this huge screen behind us with about eight sessions
06:19 running in parallel. And that's just this end of the rebroadcasting. There's probably like
06:24 15 tracks or something crazy going on.
06:27 Yeah.
06:27 But no, this year we had like 30 or so sessions about Python. And yeah, ranging a lot of machine
06:33 learning, a lot of data science, a lot of app development stuff. It's...
06:38 Yeah.
06:38 We're covering a lot more angles now and it's really exciting.
06:40 Yeah, it's super cool. It's not exactly what we're talking about today, but we'll talk about it
06:44 at some point in the future. You gave a really interesting talk on Python security and plugging
06:50 that into like operating level security, right?
06:53 Yeah.
06:54 Maybe talk really quickly about some of the stuff that's coming there and what you talked
06:57 about.
06:57 I kind of like move from project to project that I'm working on. One of the biggest things
07:01 I've been working on recently is getting auditing hooks, which was PEP 578 into CPython.
07:07 So that released in 3.8?
07:08 That released in Python 3.8.
07:09 Okay.
07:10 And now it's time for me to go around and teach everyone what you're meant to use them for.
07:14 Because it's like they don't actually do anything on their own right now. It's just a way of raising
07:21 low-level events from inside the runtime. So you'll get notifications from the socket module every
07:27 time it connects to a socket or every time a file gets opened, every time Ctypes gets used,
07:32 all of the stuff that you really want to know is going on, but Python doesn't really give you a
07:37 way to see it. And so the security applications of that are essentially logging. You want to collect
07:42 all that information. And as I said, in some variants of the talk, build a haystack of every
07:49 single event so that when you figure out there's a needle in there, which is someone attacking your
07:54 systems, then you've got a chance of figuring out what they were doing.
07:56 At least you have a record of it. It's not just like, well, it's hacked into, nobody knows why.
08:01 Right. It's like, oh, I know we got hacked because people are buying our customer database off the
08:05 dark web. It's like, yeah. And honestly, I think a lot of customers find out they were hacked by
08:09 saying, I only gave this email address to this, you know, they do like the plus thing,
08:15 like such and such plus, right? Site name or whatever at Gmail.
08:20 Or you get one of those emails. It's like, I know your password and here it is.
08:24 You're like, how did they get that?
08:25 Yeah. Yeah. Well, that speaks to a whole nother level of badness.
08:29 You know, just, I recently had to like sign into a bunch of a bank accounts. I'm trying
08:34 to consolidate just some like retirement, boring stuff. But I finally broke down and like said,
08:37 I have to do this. So here I go. And I tried to log into the bank. There was some workflow
08:42 where I created an account and I used a 30 character randomly generated password. And I couldn't log in
08:47 again. And I kept getting like an error too long sort of thing. And they were saying, well,
08:52 the password has to be 16 characters or less. And you know, the hash of a password is always the
08:58 same size, no matter how large the input. So what are they doing with that password? If they care
09:03 about the length of it? I'm not going to speculate on that one, but it's not, it's probably not good.
09:08 That may not be where you want to consolidate all of your retirement savings.
09:10 I was trying to get away from that place. So I feel all right about that. All right. So,
09:13 but what you were talking about with the Python stuff is there's really interesting hooks that you can
09:18 plug into for like compile or evaluate or like execute code. There's a bunch of neat stuff that
09:25 you got going on, right? Yeah. And that's one of the really scary things that Python can do that,
09:29 that most other tools installed on your system can't do is you can obfuscate the command line.
09:33 And so you can pass in the example I showed was like a big fat base 64 string wrapped up in a little
09:39 bit of decoding and eval to dynamically essentially decrypt code and run it without anyone actually being
09:47 able to see what it is. And so you, you don't know what it's doing until you go through and decrypt it.
09:50 The sample I showed then went off and downloaded more code off the internet and decrypted that.
09:55 Yeah. Cause once it started, then, then it's trouble.
09:57 Yeah. And so being able to hook the compile event, every time a bit of Python code gets exact or evaled,
10:02 you, you see what's going on and it's really hard. People have tried to, you know, sandbox Python
10:07 and just take those things out. And it turns out that doesn't work well firstly, because you need them
10:12 for a variety of things in the, in the language and standard library. And it's, there are other
10:16 ways to fight to work around that and to still compile code. So this way you don't block it hard,
10:23 but you get to see everything that goes through it. And then if something bad does happen, at least
10:27 you know about it.
10:27 Yeah. It's, it looks really positive and you know, I don't want to talk more about it cause
10:31 that's not really the topic of the show, but there was, Let's do that one later.
10:33 Yeah. We'll do that as another show, but that's what you were here talking about. And the audience
10:36 was full, right? Like people were really interested in this.
10:38 Yeah. There's a lot more security minded people here. I did run around and do a quick survey
10:44 or just a quick chat with everyone who was attending and it was a really interesting,
10:48 What was the mix?
10:48 Diverse crowd. It was equal parts developers, security administrator, IT management. it was
10:55 a pretty good spread across all the roles that would be interested in, in managing where and how
11:01 Python is used in their setup.
11:02 Yeah. Yeah. The people asking questions afterwards were like, I'm not a developer,
11:06 but I have to sort of oversee the execution and protection of this stuff and so on. So help me,
11:10 help me understand how to do that with Python. That's pretty cool. All right. Now let's talk
11:15 about Python and windows because it's okay. Actually. Yeah. It's okay. Yeah. Actually. Yeah.
11:20 That's awesome. You know, when I go to a lot of conferences and like, especially I think PyCon
11:26 falls under this banner, you walk in and it does feel like most people are on some kind of Mac or maybe
11:35 running Linux. Like there's some windows folks there, there's, you know, some surfaces and whatnot,
11:40 but it doesn't seem to be very, doesn't seem to be the majority. Does it?
11:44 There are more and more surfaces, which we're very excited about, but yeah, the, there is always an
11:49 army of glowing fruit staring back at you while you're speaking to that crowd.
11:53 That's right. They just stand out mocking you there with a little bite. Yeah. So it feels like
11:59 it can feel like to a lot of Python developers and especially, I think it's the most relevant
12:04 audience is the people building Python packages, right?
12:07 Yeah. Yeah. So it is certainly the most popular platform that, that and Linux for, for the people
12:14 that are building the open source stuff that we know and love and rely on. And I think what's really
12:18 interesting is that that's about the only data point that really looks like that. It's a bit of
12:23 conference bias, I think as we see it ignite as well, it's biased in the other way. Yeah. And just
12:29 through that kind of selected audience, you're going to see a certain set of people. But the problem with
12:35 that and the problem with kind of all, you know, diversity type topics is if that's all you see,
12:40 and that's what you believe reflects reality. Right, right. How would you know otherwise?
12:44 Exactly. It's not exactly the, you know, the same thing, but Scott Hanselman also from Microsoft has
12:50 a really interesting saying, he did a blog post on dark matter developers. Are you familiar with this
12:54 idea? Yeah. Yeah. Yeah. It's that there's a whole bunch of folks out there who write code,
12:59 they go to work, maybe they work at some big company. They're not so passionate that they're on
13:03 Twitter all the time, right? They're not going to conferences or the meetups. They just, you know,
13:07 they're happy programming, they do their job and they go home and they're not blogging, tweeting,
13:11 podcasting about it. And that world probably looks a little bit different, right? Like what those people
13:17 need, but it's still, they're a really important consumer and user of programming languages.
13:21 Yeah, absolutely. And I've met quite a few of those developers in through visiting like any of the big
13:28 companies or financial institutes at like in New York, I've gotten to meet some of those guys and
13:33 it's like, yeah, they show up in a suit and then they go home and they stop thinking about coding
13:37 completely for the night. That's fine. Right. Like if that's one of those, it sounds great. I wish I
13:42 could stop thinking about coding at night. I know exactly. Exactly. So let's talk about it. So it feels like
13:48 conference reality is like, I don't know, 70% Mac, 15% Linux, 15% Windows. But then in your presentation
13:57 you did at PyCon, you talked about, well, that might be what the like survey around here is, but let's just
14:02 look at the numbers, right? The real numbers. Yeah. So what are some of the numbers? Yeah. So I went and
14:08 tracked down, there's a few data sources that everyone has access to that I went and looked at. And there's a few
14:13 that I've managed to speak to some people individually and get some numbers out.
14:18 PyPI is a great source of who's downloading various packages. And so I pulled that one up and
14:24 checked out, checked out a few packages. There's no easy way to kind of query the whole thing. And it
14:30 doesn't, it doesn't really make sense to do that. It doesn't make any sense to measure like PyWin32 or
14:35 something like that, right? Right. PyWin32 is, is, doesn't get installed very often on Mac,
14:39 oddly enough. If it only badly, right? So, so, you know, I tried to look at the ones that get
14:44 installed everywhere in it and it turned out that it was roughly, you know, majority Linux and,
14:49 and roughly equal Windows and Mac, which already is saying, okay, this is different from the PyCon
14:53 crowd. Yeah. And interestingly, since then we've done some more analysis on the PyPI data and found
15:00 that there's a few packages that have long lists of dependencies that may be skewing those numbers
15:06 even further. Okay. In favor of Linux. So, so there's one particular package that, that I, I won't name,
15:13 but it's, it's one of the major cloud providers tools. All right. So if you grab it and then it's
15:18 going to grab 20 other things. So that counts as like 20 downloads from Linux or something like that.
15:22 Yeah. That counts as, well, it's going to count as a Linux download for those. And we found that that
15:27 particular package had a massive, massive spike on Linux for some reason. And I don't think anyone's dug
15:32 into exactly why, but it's like in the tens of thousands of downloads a day, well beyond where
15:39 any other reasonable package should be. Right. Okay. So those numbers are still skewed, but,
15:43 but they are saying it's majority Linux, whereas a conference is not majority Linux. I had a chat with
15:48 the, the Anaconda folks to see what they could tell me about people downloading from Condor.
15:52 Yeah. I feel like they're a little more enterprise focused and that might have a different crowd.
15:56 They're a little more enterprise focused as well. You see the, the percentage of windows
16:00 downloads increasing there. So it's roughly double what it is for Mac and Linux is still
16:04 about half of the overall downloads. Okay.
16:07 The PSF survey. And, and we've had two of these now, and I believe that there's one going on right
16:12 now. I think that's probably be over by the time we finish the time we release it. So it's a little
16:17 bit, I wish I could, we could encourage people to take it, but it'll be great to look at the 2019
16:21 results. I'm, I suspect we'll see some interesting trends.
16:24 Yeah. So, so the interesting thing that happened with that is they changed the question slightly
16:28 between the 2017 and the 2018 one. So in 2017, they didn't actually ask the question and they
16:33 looked at people's huge user agents to figure out which OS they were coming from. Right. Right.
16:39 And that one showed you half of all the survey respondents were on windows and fewer on Mac,
16:45 fewer on Linux. And then, then there was a big gap, which some of us speculated it's probably Android
16:50 in iOS phones. Yeah. Cause you can take the survey on whatever you're on, but half the people
16:55 responding were on windows, which means that's kind of like a max level, I feel like, but then the
17:02 following year they asked the question again and, but this time they let you choose multiple responses
17:06 and they say, which ones you develop for. And so the interesting, the only thing that really changed
17:10 between the two sets of data is that windows are still 50% and Linux went from about 10% up to 60%.
17:19 Wow. And so people are devving on windows, but pushing to the cloud on, on Linux.
17:24 My hypothesis, and we haven't checked it. And hopefully the current survey is going to
17:27 help clarify this is people develop on windows and deploy on Linux and, or they work on windows.
17:35 Yeah. Deploy to Linux. And so you already have a much bigger chunk of windows showing up there
17:39 than you ever see at a conference.
17:40 How much do you think Docker influences this? Because Docker is like, I feel like it would
17:47 overcount the Linux side of things. Cause you so often recreate these images and they reinstall
17:53 and reinstall, you know, like...
17:54 Definitely. But virtual environments are going to be much the same thing. So I think there's,
17:58 there's a lot of repetition, but, but I guess virtual environments are now cached for things
18:03 like PyPI. So you're not actually going to count the download again.
18:06 Yeah. Yeah. Yeah. Yeah. But a fresh, like a fresh change of like a low level part of a Docker image
18:10 might as well, or CI as well, but CI is probably cached. I don't know.
18:14 Ultimately the point that, that I eventually got to with all these numbers is we don't have a good
18:20 answer for how many people are using this. Like you go and look at, at the editors that we also
18:24 have numbers for us, a VS Code, PyCharm and their majority windows, either slim or significant
18:30 majority windows and smaller Mac, very, very little Linux. And about all we can really say is that
18:36 the numbers don't line up. They definitely don't line up with what we see at a conference. And when
18:41 you walk around PyCon and you come away going, literally everyone is running on a Mac. Then all we
18:48 can say is we know that that's not true. Right.
18:50 So I feel like conservatively, probably half the, the Python community, half the Python user base
18:56 is running on windows either for development and deployment or just for development, then deploying
19:01 to another platform. Sure. And that's, so the other stat that I pulled out just for fun, because it's a
19:05 big number, but is obviously biased. So the Python.org downloads, which is mostly where the,
19:11 mostly where windows developers will get their Python from. And we see that in the stats that's,
19:16 that is vast majority windows, but the number it's, I ran some of the analysis for one month,
19:22 about, about a year ago now. And there was 20 million unique downloaders in that month,
19:28 which is my windows for windows. Yeah. And most estimates of the size of the Python community,
19:34 like five to 6 million developers. And we got 20 million downloads for windows in that month.
19:41 So how interesting. So we don't know the exact numbers, but I think we can say that it's certainly
19:47 not a minority of the Python community. I would, I'd estimate it's about half, maybe more. Yeah. And
19:53 it's certainly a big number. Yeah. And that's about all I'm prepared to say concretely. Yeah. Yeah.
19:58 Sure. And so, I mean, maybe one of this, the takeaways from this section is we need to treat the windows
20:07 dev story importantly in the Python community because a lot of people are doing that and they're either
20:12 having a good experience and liking Python more or a bad experience and not feeling welcome.
20:17 Right. And so the thing that concerned me out of that is where, where are, like, where are these
20:22 developers at our conferences? Yeah. We have all of these Python conferences all the time and, and the
20:28 numbers vary, but there's, there is nowhere near a representative number of windows devs coming to our
20:33 Python conferences. And there's also not a representative amount of kind of pain and suffering
20:39 that you hear online. I mean, I, this is my area. So I watched the Twitter feed for, you know,
20:44 Python and windows and, and there's a lot of pain out there for a variety of reasons. and so I just
20:50 wonder how much is people try and get started using Python on windows and give up or they just don't feel
20:58 welcome because things are painful and it seems like they're just not, you know, no one's aware
21:03 of them. No one sees them. No one knows they're there. Yeah.
21:05 This portion of talk Python to me is brought to you by Linode. Whether you're working on a personal
21:12 project or managing your enterprise's infrastructure, Linode has the pricing support and scale that you
21:18 need to take your project to the next level with 11 data centers worldwide, including their newest
21:23 data center in Sydney, Australia, enterprise grade hardware, S3 compatible storage, and the next
21:29 generation network. Linode delivers the performance that you expect at a price that you don't get
21:35 started on the node today with a $20 credit and you get access to native SSD storage, a 40 gigabit
21:40 network industry leading processors, their revamped cloud manager at cloud.linode.com root access to your
21:47 server along with their newest API and a Python CLI. Just visit talkpython.fm/Linode when creating
21:54 a new Linode account and you'll automatically get $20 credit for your next project. Oh, and one last
21:59 thing they're hiring. Go to linode.com slash careers to find out more. Let them know that we sent you.
22:07 How many of those do you think are students? I do have some slightly more demographic data from the
22:13 Python in the Windows store distribution. So that gives me a little bit more information. There's some
22:18 age banding and some regional information. And that does certainly make it look like the majority of
22:25 people installing Python on Windows are college students in the US and China primarily. Okay. Oh,
22:32 that's pretty interesting. Yeah. Okay. Well, and it might not be that they're developing on it. They
22:36 might just need it to run something as well. They may just need it to run, but given how new the
22:42 Windows store distribution is, it's kind of unlikely that you'll find it unless you're looking for it.
22:46 Right. Okay. Yeah. So I guess the story is here's the numbers that you're giving us.
22:51 Right. We've got a lot of different sources and they all seem to point at generally the same trend.
22:57 Now what? What do we do about that? Yeah. Well, and so I was giving a conference talk,
23:02 right? So I had to speak to the people in the room. There's only so much value in getting up in front
23:08 of a crowd of people and telling them that someone else has to do something. Yeah. I don't like doing
23:13 that. So I was like, okay, what pieces can the people here help with? Because it's no one's fault,
23:20 really. It's like when a conference doesn't reflect the general population for its area,
23:27 it's really hard to say whose fault that is, but I think it's easier to say, knowing who you are,
23:35 who's here, here are things you can do that will be net positive.
23:38 Right.
23:39 So PyCon, as we said, it's a lot of library developers, a lot of enthusiasts, it's people
23:43 writing codes, people publishing code.
23:45 People who are getting paid to do Python development already. So they're in a different demographic and
23:50 whatnot to some degree as well, right?
23:52 Right. And so from that, I'm like, well, okay, these are the people who are potentially writing
23:57 the libraries that just grate a bit on Windows. Like for one little reason don't work well for
24:03 this Windows crowd and maybe, you know, contributing to that old Python community doesn't really think
24:09 about Windows. And so I built the talk around that and kind of went through some of the major
24:14 kind of cross-platform mistakes or assumptions that I see people make that don't actually translate
24:21 cross-platform well. Python already does a fantastic job of, you know, hiding most of that.
24:25 Right.
24:26 And then there's some things that bleed through that, that can, you know, if you're not aware
24:31 of them, then you are going to make code that doesn't work well on other platforms.
24:35 And the best part about it all is when I started going through those and find, and, you know,
24:40 planning out the right way to do things, turned out they're all just best practices anyway.
24:43 Right.
24:44 And they make you code better on all platforms.
24:46 Right.
24:46 Like don't treat paths as strings, treat them as, you know.
24:50 Right. Treat them as path objects.
24:52 Yeah, exactly.
24:52 So yeah, that's, that's one of the big ones because most people are aware, you know, Python,
24:58 not Python, Windows uses backslashes to separate path segments and POSIX uses forward slashes.
25:03 And so that's kind of an immediate difference where if you've written your code using the
25:08 string functions and it's all, you know, string dot split forward slash, that doesn't split
25:12 anything on Windows.
25:13 Yeah.
25:13 That's a bad time.
25:14 Let's start the story of like what we can do on Windows, which you say is really is kind
25:21 of like actually just best practices for Python code anyway.
25:24 But, you know, we got to get started by having Python on Windows.
25:27 Yeah.
25:27 Right.
25:28 And you've done some interesting work there.
25:30 Right.
25:30 And the fun thing is this, this actually happened between two of the times I gave this talk.
25:35 And so I had to go back and, and, and say, you know, you assume that this is true.
25:40 And yeah, and now you're right because I fixed it in between.
25:43 So, so yeah.
25:45 I fixed your assumption.
25:46 People have, have kind of got the hang of installing Python from the Python.org installer.
25:51 And one of the big differences that that has from, if you install it on Mac or Linux is it
25:57 doesn't put Python on path by default.
25:59 And there's a checkbox, but you got to check it and you got to know that it matters.
26:03 There's a checkbox, which I really don't like.
26:05 Like I put that there under protest.
26:07 Okay.
26:07 And I don't like it because when you put a directory on path in windows, it's not the
26:11 same thing as putting a symlink in kind of an already shared directory.
26:15 So you do that on, on Linux and, you know, you put it in the user's bin directory and then
26:21 it just shows up.
26:22 And the only thing that they get access to is Python.
26:24 But on windows, when you do this, you're injecting an entire path with every single file in that
26:29 directory.
26:30 All the executable stuff that's hanging out with Python.exe, right?
26:34 All the dynamic libraries.
26:36 So if some other application tries to load the Python DLL, it might find the one that
26:41 you put on path because that's how the resolution works.
26:44 Right, right, right.
26:44 And maybe that's like version one of, I don't know, some D library and they are actually looking
26:52 for version two.
26:53 And of course they're compiled against the header for version two.
26:55 So they are going to like hard crash because that's not going to line up and whatnot.
26:59 Right.
27:00 It's a big problem.
27:01 Yeah, exactly.
27:01 So, so I, I'm not a fan of putting Python on path.
27:04 That said, my, my fix for this, which I'll get to is I'm, I'm very happy with, but it
27:09 also doesn't come as like a Python three dot XE or Python three dot seven dot XE.
27:13 It would, it would just be a Python, which goes against all of the instructions that are out
27:17 there on how to run it.
27:18 Right.
27:18 All the getting started tutorials say type Python three, this pip three, that probably sources
27:24 thrown in there or dot.
27:25 Oh yeah.
27:25 Source activate.
27:26 Yeah.
27:26 There's just all these kind of little rough differences.
27:29 And the first few times I gave the talk, I pointed those out.
27:33 The last time I gave the talk, I got to actually say, Hey, there's a new package for this.
27:37 There's a new installer for Python, which comes through the Microsoft store.
27:42 It's still released by the Python software foundation.
27:45 Like it's exactly the same as the one that you get from Python.org.
27:48 It just comes in different packaging.
27:49 And the nice thing about this is this one has a more POSIX like system for putting shortcuts
27:54 on path.
27:55 Okay.
27:56 So it already comes with, it has a directory that's already on the user's path that only
28:00 has essentially symlinks in it.
28:02 I see.
28:02 And so in there, I was able to put a Python three, oh, a Python, a Python three and a Python
28:08 three dot seven or three dot eight shortcut that doesn't have any of the downsides of putting
28:13 all the other directories on there as well.
28:15 And so that now makes all of the commands available on windows as well as Mac and Linux in
28:21 exactly the same way.
28:22 Yeah.
28:22 That's such a positive thing.
28:24 So you can go there and you can now type Python three on windows and it, it means basically
28:29 the same thing.
28:29 You don't have to be an admin on the box to install it.
28:32 Right.
28:32 Yeah.
28:33 As long as you can get the store, it just lives on.
28:35 You probably are not even affecting other users on that window system, right?
28:39 No.
28:39 The only impact it may have on other users is if they install Python from the store, then
28:44 windows will go, oh, I've already got this once.
28:46 I'll give you the same one.
28:47 Yeah.
28:47 And, and it still separates everything by user, but it, it does save them the download.
28:51 Right.
28:51 Right.
28:51 But it's not, you're not going to break one of their apps by installing.
28:54 You can't install anything in their space.
28:56 They can't install anything in yours.
28:57 It's a good setup for multi-user Python.
29:00 That's super cool.
29:01 Another thing that's worth pointing out is even if you don't do that on windows 10 now, if
29:06 it's properly updated to the latest and you type Python three, it doesn't say Python not
29:11 found or Python three not found.
29:13 Right.
29:13 Right.
29:14 That was one of the big benefits of putting it in the store is it made it really easy
29:19 for the windows team to come around and say, well, what if we just put a shortcut in there?
29:24 It's like, everyone's been asking for years, you know, can you just put Python in windows?
29:27 And we figured out the best we could do without taking on a massive maintenance burden, which
29:33 was, we'll just put a shortcut in there.
29:34 And so you run Python, you run Python three and it'll bounce you to the store where it's
29:39 then one click to actually get the Python and Python three.
29:42 Then you type it again, then you're good.
29:43 Type again and you're good.
29:44 And we're actually seeing literally thousands of people a day installing Python through that.
29:49 And they, they probably maybe didn't even know that that was what they needed to do.
29:53 They just wanted to run Python.
29:54 They typed it and said, you don't have it, but click this button and you'll have it.
29:56 I've recommended it to a few kind of trainers and teachers and they absolutely love it because
30:02 they can now go into a classroom and say, just type Python three on your machine.
30:06 See what is it?
30:07 What happens?
30:07 And if it pops up with this, click install and now type Python three again.
30:11 And everyone in the room is ready to go.
30:14 Yeah.
30:14 A lot of those training situations as well.
30:16 Those folks don't have permission to install the wide open MSIs and all sorts of stuff that
30:22 will like shut down a class.
30:25 You're like, okay, the first thing we're going to do is install this.
30:28 We can't install it.
30:29 Well, this is going to be a real short presentation.
30:31 Yeah.
30:32 The next two hours are going to fly by.
30:35 Exactly.
30:36 Just, you just have to watch.
30:37 All right.
30:38 So I think we kind of started on the first thing is like, how do I run Python?
30:43 Right?
30:44 Not, things are not always in the path.
30:46 The, the path story is, is different.
30:48 Typing Python three until recently used to be a problem they would run into.
30:55 People would have to Google about like, well, why does Python three not work?
30:58 How do I get Python three?
30:59 It says I have Python installed in like my installed apps, but I type Python three and
31:03 it doesn't work.
31:04 So I think people still need to be cognizant of that because even though the fix is now
31:10 there, it's going to be a while before all the windows machines live in that world.
31:15 Right?
31:15 Yeah.
31:16 It always takes time to roll out new things and hopefully over time as more and more
31:20 people see it, then we'll see more instructions.
31:23 I'm really looking forward to people not posting new instructions every day on how to install
31:27 Python the old way.
31:29 Yeah.
31:30 And we start seeing some more, more people posting how to, how to install it the new way.
31:34 Right.
31:35 Here's the store.
31:35 Click it.
31:36 Yeah.
31:36 And, and so in an effort to do that, we actually convinced some of the, the Microsoft documentation
31:42 team to put our own, how to install Python on windows page up.
31:45 Okay.
31:46 So, so I will have to double check the URL, but I think docstopmicrosoft.com slash windows
31:51 slash Python.
31:52 We'll get you to some of our getting started with Python on windows page.
31:56 That's pretty cool.
31:57 that, you know, we invested in writing up and, and getting good steps and it'll take
32:02 you all the way through to, oh, you're a student.
32:04 Here's how to build your first game with Pygame.
32:06 You're a system admin.
32:07 Here's how to build, here's how to write a script that'll do like some file scanning.
32:11 Yeah.
32:11 So, you know, we're trying to, to move the entire world forward rather than leaving everyone
32:17 in the, you know, here's how to install Python 3.4 instructions, which I still saw pop up
32:23 recently.
32:23 Oh my goodness.
32:24 Yeah.
32:24 I definitely looking forward to a world where there's not a bifurcation of every step until
32:30 you actually get to run in your code is, is what do on Mac and Linux is what do on windows,
32:36 right?
32:36 Like another thing that, that varies is pip three, right?
32:39 Yeah.
32:40 So pip's always been a little bit better off because it would generate the, the versioned shortcuts.
32:46 It's done that for quite a while.
32:48 One of the downsides of the, the windows store installation is that you can't, you can only
32:56 add shortcuts into that directory if you're actually the installer itself.
33:00 So I have to pre-declare all of those in the package.
33:02 And it means that when you pip install a package, it can't update those global shortcuts.
33:06 And so they go into a directory that's not on your path.
33:09 pip these days will print a message saying you should add this to your path.
33:12 And if you do that, then you'll be just fine.
33:13 Okay.
33:14 But, but it does mean that most kind of command line tools that you might install with pip,
33:19 you won't get to through the usual name.
33:21 Right.
33:22 Like black or pip x or something like that.
33:24 Exactly.
33:24 Okay.
33:25 And that's always been an issue that's always kind of run into problems here and there on
33:29 Python.
33:29 Yeah.
33:30 And the recommendation for a long time for, for all platforms, in fact, has been to use
33:34 Python three dash M and the name of that command rather than trying to use where it
33:39 is.
33:40 Python knows exactly where it is.
33:41 Yeah.
33:41 And the other advantage is if you know, like that's the Python you're working with.
33:46 So we generally recommend this for pip as well, because if you pip, if you pip install
33:51 something and then Python try and import it and your path is messed up and this can happen
33:56 on any OS.
33:57 It happens on Linux, happens on Mac, happens on Windows.
34:00 Then you'll go, why can't I import that package?
34:02 Right.
34:03 You like, like you type pip instead of pip three and it accidentally goes into Python two
34:07 because that's earlier or something like that.
34:09 Right.
34:09 Yeah.
34:09 And so we definitely recommend, you know, Python three dash M pip, even for pip.
34:14 Yeah.
34:14 Brett Cannon just wrote a big article about that, talking about how we recommend Python
34:20 three dash M.
34:21 Yeah.
34:21 And for all the different things.
34:24 This portion of talk Python to me is brought to you by brilliant.org.
34:27 Let me knock something off your holiday to do list.
34:30 Gifts.
34:31 Spread the love to your loved ones by gifting them brilliant.
34:34 This really excites me because it's such a fun way to nurture curiosity, build confidence
34:39 and develop problem solving skills crucial to school, job interviews or to their career.
34:44 Brilliant's thought provoking content breaks up the complexities into bite size, understandable
34:49 chunks that will lead them from curiosity to mastery.
34:52 Go to talkpython.fm/brilliant and grab a gift subscription to help your loved ones finish
34:59 their day a little smarter this season.
35:01 That's talkpython.fm/brilliant or just click the link in the show notes.
35:05 I'll call out some false assumptions that you had that people often make about writing code.
35:12 So we touched on this first one a little bit like everyone uses forward slash for path.
35:15 Yeah.
35:16 I see this assumption pop up a lot and it normally looks like, you know, using the string functions.
35:22 So string dot split dot partition and just passing in a forward slash.
35:25 That works fine as long as, you know, every platform you're on is using forward slashes, but
35:30 there's plenty that don't.
35:31 I use the built-in path lib or os.path style to process that, even if I know it's only going to run on a POSIX system
35:39 because I don't want to have to deal with thinking about that, right?
35:42 Yeah.
35:43 As a string.
35:43 There's a lot of, Python has about five different ways you can do this, but certainly the os.path module is very useful.
35:50 And the nice thing about that is you can also import POSIX path directly or NT path directly.
35:55 If you know you need cross-platform behavior, if you like specific platform behavior.
35:59 Okay.
36:00 And so I've definitely written code that uses os.path for some things and POSIX path for other things
36:05 because that's, you know, it's going to look more like a URL or it's going to be sent to a different system.
36:09 So you have that option there.
36:10 But really, we have path lib now and we've had path lib since I think Python 3.4.
36:17 And that's just so much nicer.
36:20 Yeah.
36:20 Path lib is really nice.
36:21 And yeah, but definitely not strings, right?
36:23 Definitely not strings.
36:24 Okay.
36:25 Because I guess the tie back to Windows is right.
36:28 Like it will break on Windows.
36:30 You should do it anytime, but it will actually break, not just be less convenient.
36:34 It will break because if you get a Windows path.
36:36 And so the thing that Windows makes a little more complicated here is if you give Windows a path that has forward slashes,
36:41 it will go through and correct it for you most of the time.
36:44 Yeah.
36:45 Not all the time, but most of the time it'll correct forward slashes to back slashes.
36:48 But any path that it gives you or any path that a user gives you is going to have back slashes in it.
36:54 And you can't split on forward slash then.
36:56 Yeah.
36:56 Because you'll always get one element back and that's probably not what you wanted.
37:00 No, that's not good.
37:01 Also, route paths are kind of funny, right?
37:04 Like it could be weird maps or volumes or other stuff, right?
37:07 Yeah.
37:07 Not just C colon backslash.
37:08 It gets very interesting, the kind of range of shortcuts for identifying a drive or amount point.
37:14 So there's the kind of internal system representation, which for a drive often looks like a GUID.
37:20 Like it's a globally unique identifier and no one's typing those.
37:24 So we have a shortcut that's going to be like C colon or D colon.
37:27 There's SMB shares, which are, you know, backslash, backslash, computer name, backslash to N slay.
37:33 Which part of this is the root of the drive?
37:35 It's like if I'm dotting up the directory, how far do I go before I have to stop?
37:39 Because it varies and it's different.
37:42 And the Python libraries know how to handle that.
37:45 We've built that logic in.
37:47 Yeah.
37:47 So just don't use strings for paths.
37:49 Don't use strings for path.
37:50 Yeah.
37:51 Thank you.
37:51 Absolutely.
37:52 Use pathlib.
37:53 Speaking of paths, tilde.
37:54 tilde slash is always good.
37:57 That gets me home, right?
37:57 There's no place like tilde slash.
37:59 No place like tilde slash.
38:01 Yeah.
38:02 People love putting their configuration files in tilde slash.
38:06 Yeah.
38:06 And, you know, so Windows doesn't have tilde.
38:09 Like tilde is just a path character.
38:11 You can put that anywhere you want.
38:13 And it's just another part of the name.
38:15 That lives in the working directory.
38:17 Right.
38:17 That lives exactly where you are right now.
38:19 It's where your heart is, not where you want to be.
38:21 But people do make the, you know, they do very quickly figure out, oh, I should be using the user profile environment variable or figure out the home directory some other way to do that.
38:31 But even that, depending on what you're planning to use it for, doesn't necessarily line up.
38:37 Like you see tilde slash, you know, dot and something for a lot of configuration files on Linux.
38:44 But on Windows, that just gets thrown into the root of the user's directory, which actually has a set of subdirectories for different purposes.
38:52 And you start digging down, particularly for...
38:55 Like app data, local app data roaming, all that kind of stuff.
38:58 And they all have different reasons and different behaviors.
39:00 So like app data roaming will actually propagate between different machines on a network if that's configured for that.
39:08 So anything you put there is going to be copied or maybe copied onto a network share and automatically copied down if the user logs in somewhere else, which is really handy.
39:16 But if you're using it for, you know, 10 gigabytes worth of log files, then everyone's going to be real upset about saturating the network and login taking so long.
39:23 Yeah, exactly.
39:24 The domain controller is out of disk space.
39:26 We don't know why or wherever it gets stored.
39:27 But the other thing is that's a very hidden directory to users.
39:30 Like it isn't...
39:31 It's about as hidden as, you know, a dot file.
39:33 Yeah.
39:34 But if you're creating something that you want the user to see and modify, then they have a documents folder for that.
39:40 And you probably want a subdirectory in that documents folder anyway, just for organizational purposes.
39:46 And so you start looking at a very different layout from where you would keep all of this stuff on a POSIX-based system.
39:52 It makes me crazy when every program thinks it's projects folder needs to live in the root of my user directory.
39:59 Like, yeah.
40:00 Wouldn't need to be topmost.
40:02 Come on.
40:02 Doesn't need to be top.
40:03 And that doesn't even help on Windows because it's such a pain to get there.
40:06 Yeah.
40:06 Because all of the shortcuts go deeper.
40:08 Yeah.
40:09 Documents is really easy to get to.
40:10 Pictures is really easy to get to.
40:11 Videos is really...
40:12 That random folder you created is very hard to get to if you don't know how.
40:15 Gotta use the address bar of the file stuff.
40:18 Yeah.
40:18 For sure.
40:19 So the fix for all the path problems were to use some of the built-in path libraries.
40:24 What's the fix for this?
40:26 So this one, the recommendation I have is to use Apters, which is a module made for this purpose.
40:32 It's slightly opinionated.
40:35 So you will see, you know, good programs not behaving exactly like it does.
40:39 But it's a very simple module.
40:41 It's a single file.
40:42 So you may even just copy it into your project and keep it around.
40:45 But it lets you query for a specific kind of purpose.
40:49 And so you can say, give me the user's data directory.
40:51 Give me the user's configuration directory.
40:53 Give me a cache directory.
40:54 Give me the documents directory.
40:55 Yeah.
40:56 I believe it will give you the documents directory.
40:59 I think that may be one of the ones that's missing.
41:01 Okay.
41:01 Well, you could obviously get the home directory and add documents.
41:04 And that's exactly it.
41:05 And that one's not too difficult to add in if you find yourself needing that.
41:10 But it does it cross-platform.
41:12 So you import the module and you query for a directory.
41:15 And it will pick depending on what platform you're on and give you a sensible layout that's
41:19 not going to surprise, not going to upset anyone who's using it.
41:22 Yeah.
41:22 That's great.
41:23 Strings.
41:23 Strings are also interesting.
41:25 Well, yeah.
41:26 Unicode.
41:28 Unicode.
41:29 Unicode is the interesting thing.
41:30 I had this section of my talk got better and better every time I gave it because people
41:34 came and gave me more context and more information.
41:36 Yeah.
41:37 All right.
41:37 But let me pose you a trivia question here.
41:40 Which was invented first or which was released first?
41:44 Windows 1.0 or the Unicode standard?
41:47 I would initially guess Unicode, but I'm thinking this might not be right.
41:51 You'd think so.
41:52 Unicode has been around for a long time.
41:54 Stuff in quotes.
41:55 It doesn't seem like that's totally new.
41:57 It seems like that should have been right at the beginning.
41:59 It should have been.
42:00 Unfortunately not.
42:01 Windows came out first.
42:03 There were no emojis.
42:04 That's the problem.
42:05 Yeah.
42:05 No one wanted emojis at that point yet.
42:08 But because Windows came out first, they had to handle internationalization without Unicode,
42:12 which is why the code page system is there.
42:14 And there were previous systems that were already using it.
42:17 So this well predates Unicode regardless.
42:20 But it was released in Windows.
42:22 And about six years before Unicode even came out, it was released in Windows.
42:25 Which means that you have this very ingrained system of code pages and 8-bit character encodings
42:32 that now you have a compatibility burden.
42:35 And so when Unicode did come out, then it just wasn't possible to go back and say,
42:40 well, forget all of that.
42:41 We're going to switch to Unicode.
42:42 Because so much of it was at the C level where you pass char pointers.
42:46 Yeah.
42:47 The char pointers are the wrong size for Unicode.
42:48 And so, okay, trivia question number two.
42:50 Which came first?
42:51 UTF-8 or UTF-16?
42:53 You start with a smaller one, right?
42:55 You start with a smaller one, yeah.
42:56 UTF-8?
42:56 Afraid not.
42:58 UTF-16.
42:58 In fact, UCS-2.
42:59 So the two-byte character encoding was the first one.
43:02 Yeah.
43:03 And turns out Windows did actually go, oh, we should adopt this because this is now the
43:06 standard.
43:07 And that's why the Unicode encoding is two bytes throughout Windows because that was the
43:12 official standard at the time Windows said, oh, hey, let's do this.
43:15 And then UTF-8 came, it was proposed like four or five years later.
43:19 And eventually, and now that's the standard.
43:21 And I have no doubt that if Windows kind of restarted.
43:24 It would just be pure UTF-8.
43:25 It would just be pure UTF-8.
43:27 Absolutely.
43:28 You do get some bloat on a number of languages and a number of very important languages to
43:33 Windows.
43:34 So arguably, there's a kind of equalization of kind of memory wastage for certain character
43:41 sets.
43:41 If you're in English, then yeah, UTF-8 is vastly more efficient.
43:44 But as soon as you get into kind of many of the Asian languages and some of the European
43:50 languages, the 16 bits...
43:52 It takes more bytes to actually do the UTF-8 stuff?
43:55 You end up with every single character taking four or five UTF-8 bytes.
43:58 Okay.
43:58 That can be a lot.
44:00 Whereas it would only be one or in some cases two UTF-16 words.
44:04 Yeah.
44:04 Which averages out to be smaller.
44:06 So maybe there's a case for either of those.
44:08 But just for historical reasons, Windows has ended up with UTF-16 as kind of the default
44:15 choice of Unicode.
44:17 And there's no real way to go back and undo that at this point without massively disrupting
44:22 the entire ecosystem.
44:23 No one's rewriting Windows with breaking changes that big.
44:26 Yeah.
44:27 And so what that leads to, as far as Python's concerned, is a kind of fundamental difference
44:33 in how paths get passed around as strings.
44:34 Because on POSIX, it's bytes.
44:36 In the lowest level, it's bytes.
44:39 And when it comes into Python, then you can keep it as bytes and pass it back out as bytes
44:43 and kind of make sure that nothing changes and gets disrupted in the way there.
44:47 And Windows has the APIs for that.
44:49 But it's doing a silent conversion in the background through the old legacy code page system.
44:53 Okay.
44:53 Which can lose data.
44:55 It can absolutely lose data.
44:57 And it seems semi-random.
45:00 This was a big Python 2 problem, was it would do this.
45:03 And so you get...
45:04 This is one of the major breaking changes from 2 to 3, honestly, right?
45:07 Like in terms of the effect that it had.
45:11 In terms of the...
45:11 Yeah, in terms of the effect.
45:12 But it's also one of the most positive ones.
45:14 Because I heard from many, many students in particular...
45:18 Sure.
45:18 ...who logged into Windows with their name.
45:22 And their name is Chinese characters or Korean characters.
45:26 It's a language that Python 2 could not support.
45:30 And sometimes they do it on machines where the code page, the legacy support for Windows, can't handle it either.
45:36 I can't even say my name.
45:38 Yeah.
45:39 That's crazy.
45:39 They couldn't even print their own...
45:41 It made them feel terrible.
45:42 Yeah.
45:43 So I'm...
45:44 You know, the break for that for Python 3 was painful.
45:47 But then you have...
45:48 It was needed.
45:48 But then you have a handful of other libraries that still use bytes for paths because it's more performant in their context.
45:56 But it's also going to break these people again, even on Python 3, if you're forcing all the file system stuff to go through this arbitrary encoding.
46:04 And so the preferred one is to just use string on Windows.
46:07 Right.
46:08 Yes.
46:08 STR.
46:09 Works great.
46:10 STR instead of bytes.
46:11 Yeah.
46:12 And in fact, it works fine on POSIX as well.
46:14 We've implemented on that side the conversion for file system stuff to be perfectly round trip.
46:19 So even if there's characters in paths that, you know, if you converted to text would be corrupt and it would throw exceptions, we actually preserve those and they'll pass back in.
46:29 So there's a little bit of a performance impact.
46:30 But...
46:32 It'd be better to be slow and right than fast and wrong.
46:34 Absolutely.
46:35 Absolutely.
46:36 Nice.
46:36 And that's a super easy fix, just like use string.
46:38 Well, it's never quite as easy as just use string.
46:42 But where it gets real interesting is if you're doing things like reading in a list of files of the file system and writing it out to another file, because you're in control of that encoding.
46:51 So Python has not and probably will not change the default encoding of a file.
46:58 So, you know, you open a file to write text to it.
47:00 What is the default encoding?
47:00 The default on...
47:02 The default is the system locale, typically.
47:05 Okay.
47:05 Which for most non-Windows users these days is UTF-8.
47:09 Yeah.
47:10 And for every Windows user is whatever the legacy encoding is.
47:15 And this is a backwards compatibility thing.
47:17 We would love to change it to be UTF-8 by default.
47:19 But now you can't read in the file that you wrote with the previous version of Python.
47:24 And that...
47:25 Yeah, it's tricky.
47:25 That's just seems...
47:26 That's a hard sell.
47:27 It's very disruptive.
47:28 Very disruptive.
47:29 And concerning, like, what do you mean my file is corrupted?
47:32 Yeah.
47:32 Yeah, that won't feel good.
47:34 Yeah, and so even opening a file to write to, if you want it in UTF-8, then you should just specify that.
47:39 I always put UTF-8.
47:40 I wasn't sure what I'd get if I don't put that, though.
47:42 Yeah.
47:43 You will get...
47:44 It's not entirely random.
47:46 Yeah, but it's not entirely the same, always.
47:48 It's not a complete encoding.
47:51 Okay.
47:51 So there will be characters that can't be written out in that.
47:54 All right.
47:54 Well, let's maybe round this out with one more false assumption here.
47:59 We're sitting here looking at my very fancy Surface Book Pro.
48:03 No, I mean MacBook Pro.
48:04 And I'm a library developer.
48:08 And maybe I can't test on Windows.
48:11 Like, I'm sympathetic.
48:12 Yeah.
48:12 Like, half of my users are Windows developers.
48:15 But I can't verify whether my library works or not.
48:18 Yeah.
48:18 And I get this one.
48:19 Like, it's very easy to...
48:21 Or it's not very easy to get a Windows setup, necessarily, that it's very hard to switch kind of the platform you're used to to another one just for the sake of being able to address all of your users.
48:34 But at the same time, that's not...
48:36 That's like kind of drawing the line too close.
48:38 And it's like, you know, I'm aware of a problem.
48:41 And I'm aware that I need to solve it.
48:43 And I think of one solution and that's too hard.
48:46 And so I stop thinking about it.
48:47 Yeah, yeah.
48:47 That's hard.
48:48 So no.
48:48 And that's kind of what I see happen occasionally here.
48:51 And it just, you know, it makes me, you know, just choke up a little bit because I'm like, that's just bad and lazy.
48:59 Yeah, and so close.
49:00 And we have so many better options these days.
49:02 And it's really saying, thanks, but you're not welcome here to like half the users.
49:08 Absolutely.
49:08 Yeah.
49:09 Yeah.
49:09 And I could get it 10 years ago.
49:11 Because 10 years ago, we didn't have GitHub.
49:15 Or if we did have GitHub, we didn't have the reach of GitHub like we do now.
49:18 Right.
49:19 Or Azure Pipelines or all the CI.
49:21 Azure Pipelines.
49:22 Like I have GitHub Actions.
49:24 We didn't have all of these things where you can either set up to do it automatically and not need to own the machine yourself.
49:30 And we didn't have the reach to be able to say, hey, I need help with this.
49:34 Can someone come and help me test on Windows?
49:36 Because that's how it always happened, essentially.
49:39 Honestly, I think the hardest one to, if it's not you, the hardest one to test for is Mac.
49:44 Yeah.
49:45 Right?
49:45 I test none of my stuff on Mac.
49:47 That's not quite true.
49:50 But I do it all through CI.
49:51 Yeah, exactly.
49:52 But it's tougher to get CI for Mac.
49:54 It is.
49:55 Yeah.
49:56 It is.
49:56 But Windows and Linux are pretty easy to get that.
49:58 They're pretty easy.
49:59 And Azure Pipelines and GitHub Actions both have Windows, Mac, and Linux.
50:03 And I think at this point, they have multiple choices for all of those.
50:07 Okay.
50:07 So you can do like Mojave versus Catalina.
50:09 I think Windows 7 versus 10 or something.
50:12 I don't think we're offering Windows 7 as an option on any of those.
50:15 You don't want to encourage that?
50:15 The builds actually run on Windows Server.
50:17 Not even Windows Client.
50:18 So you do get a choice between Windows Server 2016 and 2019.
50:23 And choice of like the Visual Studio version, which is primarily, you know, people should
50:27 just be on the latest for the most part.
50:29 Python stuff is not that involved in the build tool set to really need to, you know, I must
50:34 stay on the old one anymore.
50:36 We made sure that Python works with future builds as well.
50:39 So you can build for old versions of Python with newer tools now.
50:42 Yeah.
50:43 So that's cool.
50:43 So the options and the opportunities there is really good.
50:47 And they're all free.
50:47 Like it doesn't cost anything to just put on your page.
50:51 I'm looking for someone to help with Windows maintenance.
50:53 And it doesn't cost anything for an open source project to be on GitHub Actions.
50:57 Right.
50:58 And people are probably excited if they're working on Windows.
51:01 Like, oh, this is a really easy way for me to contribute to this project.
51:04 Yeah.
51:04 Right.
51:05 Like all I got to do is sort of like run the test and just try a few things out.
51:08 You'll get more contributors because you're not telling them you have to switch to Linux
51:12 to contribute to my project because you've got the CI running on Linux as well.
51:15 Right.
51:16 So it opens up your pool of contributors and it helps with releases.
51:19 One of the biggest problems we see every time we release an update to Python.
51:23 So Python 3.8 came out and we're seeing this happen a bit is packages don't have wheels
51:28 ready.
51:28 They don't have builds that like they're not actually ready for Python 3.8.
51:32 And once you've got a CI setup going, which is almost automatic.
51:36 Yeah.
51:36 It's almost automatic.
51:37 As soon as the CI service has that version of Python on there or has a way to get it sooner
51:43 and, you know, we're working on making that happen faster, then it's very easy to just
51:48 spin another build and release that.
51:50 And all of your users are now successful at installing your package.
51:53 Good advice.
51:54 So that pretty much wraps it up.
51:56 You want to give us the quick summary?
51:58 The quick summary.
51:59 The checklist.
51:59 You had a checklist.
52:00 You don't have to remember all this.
52:02 Here's the checklist of what you got to do.
52:03 Yeah.
52:04 It annoys me when I see people holding their phones up at me while I'm speaking because
52:07 all of my slides build up.
52:08 Yeah.
52:09 And so like there'll be stuff on the slide that's bad and a big red line is about to appear
52:12 through it and someone's already taking a photo.
52:14 They're going to share it on social media now.
52:15 And I'm like, no, no, wait, wait, wait until it gets crossed out.
52:19 Yeah.
52:19 So I told everyone to wait for the checklist at the end of the talk because I did want to
52:22 make this really actionable and really easy for people to follow up.
52:25 So the things that I would recommend you check just before the next release of your project,
52:30 anytime you feel like it, does the dash M option work on it?
52:33 So if you've got a script entry point, can you also start your project running by typing
52:38 Python 3 dash M name of your project and document it.
52:41 Tell your users this is how you can use it.
52:43 Yeah.
52:43 Are you manipulating paths by hand anywhere?
52:45 Like, do you have any dot split instead of OS dot path dot split or path lib objects?
52:50 I like this recommendation because it's, it's just like you should do the thing that's easier
52:55 and safer and you'll be, you'll be in good shape.
52:57 Yeah.
52:58 Do I put configuration in weird places, which, you know, arbitrary paths for storing stuff.
53:03 It can make a mess, but it can't, you know, you can lose information and make things a
53:07 little harder to find.
53:08 Are you still using bytes for strings?
53:11 If you've gotten out of Python 2 and into Python 3, then there's no need to do that anymore.
53:14 That was the problem that we were trying to move people off.
53:17 So feel free to stop, you know, just use the string type.
53:20 The string type is very optimized for what it does.
53:22 And do you have, you know, continuous integration tools or collaborators on your project?
53:27 Like if it's just you on the project and the problem is that you are not representative
53:34 of your entire audience.
53:35 No one person can be.
53:36 Yeah, no matter who you are or what you do.
53:37 Yeah.
53:37 No matter who you are, there are people out there who are using your code.
53:40 Who are doing things differently from you.
53:42 And with continuous integration tools, GitHub Actions, Azure Pipelines, you can kind of have
53:48 automated systems that look like more of your users, but just welcoming more people in to
53:52 contribute and collaborate.
53:53 Even if it's just, hey, I'll email you when I'm about to do a release.
53:58 Can you run, you know, your tests on it?
54:00 And a lot more people are willing to do that than you think.
54:04 Yeah.
54:04 All right.
54:04 Well, it's all good advice.
54:06 And I definitely think the stats that you laid out are pretty interesting.
54:10 So thanks.
54:11 Yeah.
54:11 Not the world we often see around us, but it's the world as it is.
54:15 At least as good as the stats can measure from what we're using there.
54:19 Cool.
54:20 All right.
54:20 Well, before we wrap up the show, let me ask you the final two questions.
54:22 If you're going to write some Python code, what editor do you use?
54:25 I'm bouncing between editors all the time right now.
54:27 What's in the orbit that you're hitting?
54:29 I use Visual Studio until it annoys me.
54:32 Then I use Visual Studio code until it annoys me.
54:34 Then I use Notepad 2 until it annoys me.
54:36 Then I go back to Visual Studio and that's my code.
54:39 That's the three-body problem, the three-editor problem?
54:41 The three-editor problem.
54:41 Yeah.
54:42 Yeah.
54:42 Indeed.
54:42 And then notable PyPI package.
54:44 Oh.
54:45 What have you come across lately that's like, oh, this is pretty amazing?
54:48 Oh, I forgot this question was going to be here, so I hadn't thought about it.
54:51 Yeah.
54:51 See, this is like improv too.
54:53 On the spot.
54:54 Yeah.
54:54 What was I?
54:55 I was playing with something the other day that I really enjoyed.
54:58 While you're here thinking, I'll tell you about one I found recently that I thought was kind
55:00 of cool is HTTPX.
55:01 Oh, yes.
55:02 Okay.
55:03 I do like that one.
55:04 I like it because it's requests compatible, but it also does HTTP2 and async.
55:09 And then there's also some intermediate, simpler async parallelism built in it.
55:13 It's a cool one.
55:13 I've been helping promote that one.
55:15 It's in its early stages.
55:17 It is.
55:18 They're looking for contributors who are interested in the next big HTTP project.
55:22 So I'm excited about that one.
55:24 I guess I can't claim it.
55:25 Yeah, you claim it.
55:25 Go ahead.
55:25 I can claim it.
55:26 Okay.
55:26 We both like HTTPX.
55:28 Yeah, it's a good one.
55:29 Yeah.
55:29 It is early days and it could use some help, but I like it as well.
55:32 I think it's got promise.
55:32 Cool.
55:34 All right.
55:34 Well, Steve, final call to action.
55:36 People are working on their packages or working on their non-Windows machines.
55:41 What can they do to welcome the Windows people?
55:44 I think it's literally just that.
55:46 Like, welcome the Windows people.
55:48 You know, I gave a few simple things you can do to make them feel welcome, but it really just
55:52 is.
55:52 This also works on Windows, or if it doesn't, we want it to.
55:56 You know, please help.
55:57 Yeah, they got the checklist.
55:58 Yep.
55:59 All right.
55:59 Well, thanks for being here.
56:00 Great.
56:00 Thanks.
56:00 Bye.
56:01 Bye.
56:01 This has been another episode of Talk Python to Me.
56:05 Our guest on this episode was Steve Dower, and it's been brought to you by Linode and
56:09 Brilliant.org.
56:10 Start your next Python project on Linode's state-of-the-art cloud service.
56:14 Just visit talkpython.fm/Linode, L-I-N-O-D-E.
56:19 You'll automatically get a $20 credit when you create a new account.
56:22 Brilliant.org encourages you to give the gift of critical thought and knowledge.
56:27 Visit talkpython.fm/Brilliant and grab a gift subscription to help your loved ones
56:32 finish their day a little smarter this season.
56:34 Want to level up your Python?
56:36 If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
56:41 Or if you're looking for something more advanced, check out our new Async course that digs into
56:46 all the different types of Async programming you can do in Python.
56:49 And of course, if you're interested in more than one of these, be sure to check out our
56:53 Everything Bundle.
56:53 It's like a subscription that never expires.
56:56 Be sure to subscribe to the show.
56:57 Open your favorite podcatcher and search for Python.
57:00 We should be right at the top.
57:01 You can also find the iTunes feed at /itunes, the Google Play feed at /play,
57:06 and the direct RSS feed at /rss on talkpython.fm.
57:10 This is your host, Michael Kennedy.
57:12 Thanks so much for listening.
57:14 I really appreciate it.
57:15 Now get out there and write some Python code.
57:16 I'll see you next time.