Python Bytes - #24 I have a local PyPI server and so do you!

Episode Date: May 3, 2017

Topics covered in this episode: * Learning Python Series by Doug Farrell, published on dbader.org* Geeking out in your older years Local package store Modifying the Python language in 6 minutes col...orful Five steps to add the bling factor your Python package Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/24

Transcript
Discussion (0)
Starting point is 00:00:00 Hello and welcome to Python Bytes. It's episode 24 and we are going to deliver Python news and headlines directly to your earbuds. This episode is recorded on May 2nd, 2017 and is brought to you by Rollbar. I'm Michael Kennedy. And I'm Brian Ocken. And we're here to bring you a bunch of Python news, but this time it's a little different. Normally we're broadcasting from two secret locations in Portland, Oregon, but this time, Brian, you're dialing from slightly farther away. Yeah, I'm just south, what, southeast of Munich today. Right on. Well, welcome to Europe. Let's start with learning Python out of Munich. Yeah, so this is one of the, I think a listener of the show contacted us, said he wrote a learning Python series, but he wrote it for a group called Robotics and Beyond.
Starting point is 00:00:52 And it's a STEM educational space, which really looks cool. But he's, I think it looks like a nice tutorial. And he's publishing it on Dan Bader's site, dbader.org. And the first in the series is Let's Program with Python Statements, Variables, and Loops. And I think he's coming at it from a space of if you, yeah, just really getting started, haven't done much. And I like he's even talking about,
Starting point is 00:01:22 goes through even what is programming. He's assuming people haven't done programming before so talking about how it's telling people how to how you're telling the computer how to do steps and and um and you know it's it's hard for me to put my head back in the space of new to programming but um i think this is it looks like a something that might be good for um i don't know what age group, but it'd be good. Yeah. Well, we're going to talk about a lot of different age groups, but way to go, Doug.
Starting point is 00:01:52 That's awesome. It's really hard to get rid of the curse of knowledge, right? Once you've learned a thing, it's really hard to see it with fresh eyes and understand the challenges and stuff. So that's really cool. And don't you wish something like robotics and beyond existed when you were a kid? Yeah, I do. And one of the things that I like also about having lots of different people tackle the new to programming space is that everybody learns differently. So you might look at one series and go, man, I just don't get it. And then look at somebody else's
Starting point is 00:02:21 and it just clicks like this. one uses Turtle Graphics and stuff. I haven't seen people use Turtle Graphics very much recently, so that's kind of fun. Oh, yeah, very cool. Nice. All right, that's a great one, so check that out. If people ask you for how to get started programming, right, maybe kids, there's a lot of good options.
Starting point is 00:02:39 Here's one more. So speaking of learning to program, I picked one that is an actual academic paper, but I felt it was pretty interesting. This is done by Philip Guao. I've had him on TalkPython a few times. In this one, he's talking about helping older adults learn to become programmers or become more proficient in programming. So like what you were just talking about, there's a lot of, hey, you're a young kid, you want to get started with robots and programming, and here's how you do it. And we'll get you going to, you know, launch your career and stuff. But Philip said,
Starting point is 00:03:15 like so many of these resources are focused on the young, you know, teenage to early 20s group starting their career. But how much do we really know about people who are 60 to 85 years old who are just learning to program? So he actually wrote a proper academic paper and did a bunch of research on those guys. Wow. I think that's cool. It is really cool. The age group, I guess I wouldn't expect people from in the, like, I guess you've listed 60
Starting point is 00:03:51 to 85. Was that the age group of the respondents? That was the age group of the respondents. Yeah. If you were outside of that age range, mostly younger, then you were sort of not included, right? Like it was really focused on people who were basically either about to retire or who were retired. And it looked at a couple of different aspects, like why are they
Starting point is 00:04:11 interested in learning a program? What challenges do they have that they share with everyone is learning a program? Like what's a variable? Ah, what's a pointer, right? Like everybody suffers that, but there's also specific challenges for that age group. And then also, you know, just what are they using to learn and some of the lessons on how many we can make the whole environment better for those guys as well. I think that's great. Yeah, I do too. So I think it's interesting to look at what some of the reasons why people in this age group were learning to program. Some of them just said like, look, I'm now retiring and I've always wanted to learn to program. And maybe I did something technical, like maybe I was a scientist, but I never really got around to really learning to programming.
Starting point is 00:04:53 So that might be one reason. Another was connecting with grandchildren. So a lot of these folks have children who are maybe taking this robotics and beyond type course. And they're like, hey, I would love to do that with my grandchild. But let me I got to learn Python myself, right? Another big opportunity here is there's a pretty big gap between people can do programming and people are teaching kids. And so people in this age group also have a lot of time, if they're retired, to maybe donate, you know, an hour or two a week at some place mentoring or something like that so maybe they could fill in this like sort of help teachers at high schools and middle schools with actually teaching programming and not just like the coding class teaches html right something like that
Starting point is 00:05:35 as well as like um just keeping mentally active and pursuing hobbies right like their hobby is airplanes and they are going to create something that works with airplanes somehow. Yeah. I think, um, and then I could see probably the, uh, the maker space getting into that and people trying to program Raspberry Pis and stuff like that. Yeah, absolutely. Absolutely. There's a lot of cool stuff. A lot of the cool times with like the, the micro Python type of stuff as well. So if you're interested in this, check this out. I'm also planning on doing a full proper talkthon episode with Philip in a few weeks. So we'll catch up on that and go deeper on that show. Okay, great.
Starting point is 00:06:10 Hey, so next up, I've got something that I've been, we talked about, I can't even remember what episode. I was looking for a good way to have a local PyPI server just like so you can sort of not have to go out onto the, to Pi PI all the time. And especially on the plane trip, when I was flying over here, I knew I wouldn't have an internet connection. So I wanted to make sure I had a, a cache of all of the, all of the packages I needed for, for while I was programming on the plane. And, um, I don't know when this crept in, but there's a pip has download now. And I don't think it used to always have that, but you can just, and I've got the, I put just the few lines of code you need in, in our show notes, but it's it's just, you, you go to a directory you want
Starting point is 00:06:58 and you type pip download and some package and it downloads that package and all of its dependencies and doesn't install it it just stores stores the wheels in that directory yeah that's super cool so you can you can basically create an offline version of pypi in it it just it's really quick you can even list multiple packages on the line i just i knew like the 10 or 12 that i needed and didn't know what their dependencies were and just filled up a directory in like 10 minutes or less. And then I was ready to go. And then you just have to use the, um, when you're doing the install, you do the dash dash no index and dash dash fine links and point it to your directory. And then the rest is the same. You just give it a package and this includes like version numbers.
Starting point is 00:07:45 So you can have multiple versions in there as well. So anyway, just wanted to share that with everybody. Nice. Do you know if I can, can I give it like a requirements TXT and say, download that? You know, download the results of that. I suspect you can, right?
Starting point is 00:07:59 Probably pip download dash R requirements, you know, dot TXT, I bet. Probably. I don't usually work with requirements files, so. Nice. Okay, this is a cool thing. So if you maybe were going to be stuck on an airplane and trains and other places for like 18 hours straight, you might want to take some packages with you, right? Yes.
Starting point is 00:08:20 That's awesome. Okay, so that's a really, really cool tip there. I know there's the like the dev pi and the actual local proper pi pi servers that you can set up and just point at the URL, but I didn't know about this, this local download option. So this is great. And that the all those other little pi pi servers, I know that the setup says that they're really easy, but I haven't been able to get it to work for me. So I don't know what I'm doing wrong. But anyway, so this is easy. Yeah, this definitely like everybody has a directory, so they can do it. You don't have
Starting point is 00:08:51 to have the right infrastructure around it. That's cool. All right. Before we get onto the next item, which is about adding features to the Python language itself, I want to just say thanks to Rollbar. You guys have heard me talk about Rollbar a lot. You know that I use Rollbar on my websites and really, really like Rollbar. Basically, all you have to do is pip install rollbar, maybe include a line or two in the config or set up for your Python web app. And it's tracking all these errors and sending you reports and notifications with lots of details anytime it happens. So these guys are going to have a booth at PyCon. They're going to be just like us, Brian. We're all going to have booths at PyCon. Yeah. I'm going to have to go get a Rollbar sticker for them.
Starting point is 00:09:34 Yeah. Definitely get a Rollbar sticker, maybe a Rollbar shirt. I don't know what kind of swag they're bringing into the show, but they want to make sure that you know there's a booth for Rollbar at PyCon. And so drop by and they'll give you a demo and give you some kind of swag to go with it. Awesome. Awesome. Yeah, so just check them out, rollbar.com slash pythonbytes. Get the bootstrap plan for free, which is 100,000 events and 180 days of retention.
Starting point is 00:09:54 And hopefully you don't use up that many errors, but if you do, they got you covered. All right, so you know what would be cool? Is if we could have increment and decrement operators in python i mean we can do plus equals one but i think of all the characters we're wasting there what if we could just do plus plus yeah do you know why python doesn't have increment and decrement operators i have a theory but i don't actually know i don't know why do you certainly the language was created after no i mean it was created after c and c, right? So it's not like it wasn't known
Starting point is 00:10:25 as a possibility, I suspect, it was to keep it more explicit, right? You know, one of the challenges of plus plus and minus minus and those types of things is a lot of languages that support them support like two variations, like plus plus variable and variable plus plus. And it's always like, okay, well, what that increments it and then returns the incremented value versus returns the original value. And then increment is just like, it's kind of confusing. Like why is like increment confusing? And so I suspect Kuita is just like, all right, just simple.
Starting point is 00:10:57 It's also like, like in C++, it matters which side of the assignment operator it's onto. If it's an L value and R value. Yes, all those things. And so it doesn't have one. But friend of the show, Anthony Shaw, said, let's see what it would be like if we tried to add one. And I think this is cool because it actually,
Starting point is 00:11:18 his article on Medium takes you through step-by-step what it is you need to do to add a new feature to the Python language. So basically, he writes an article that adds plus plus and minus minus to CPython. I like where he's going with it and also teaching people how to do this. It's kind of neat. Yeah, it certainly takes some of the mystery of like, well, how would you even start out of this? So he says, look, there's basically five or six levels. So you're going to start by doing a pep to get agreement on what the language feature is going to be.
Starting point is 00:11:48 Then there's a grammar file that describes what the statements in Python are. You don't want to just cram it into CPython, the execution engine, because things like PyPy and other implementations, you want those to stay consistent. So there's this grammar file they all share. It talks about how to add them. And it turns out it's like super easy to add these new things. Then there's the lexer that parses it. Lexer that goes through and, sorry, turns it to tokens. Then the parser takes the tokens to abstract syntax trees. And then there's a compiler that actually compiles it to instructions. So he goes through all the steps and shows you how it works and even has his attempt to add this feature to Python itself out on GitHub,
Starting point is 00:12:31 if you want to check it out. So he's got a working version with plus plus. That's pretty cool. Maybe we could get him to add begin and end to blocks. Hopefully he's no. And curly braces. We all love the curly braces. No, just kidding. Okay, so that's awesome. Another thing that you brought up that I like is colorful, right?
Starting point is 00:12:54 So I think so many of the apps that we create in Python are sort of terminal level or CLI type apps. So people really could do more to make them pretty, right? Yeah, so I've been working a lot with PyTest lately. And one of the great benefits of it is the color in the terminal window. And working with terminal colors, this is often not very fun.
Starting point is 00:13:16 But this colorful project has actually got a syntax that's pretty darn readable. And once you've figured out what colors and what syntax what different parts of your interface your command line interface you want different colors i don't think you're going to really have to care like really muck with it too much using colorful and it even has things like piping colors to strings and like different plus and and operators that that make sense with colors and i like what they're going doing with this yeah that's cool i do as well and the couple of things that really stood out is nice to me one is the syntax is pretty straightforward on how you use it
Starting point is 00:13:58 the fact that you can use hexadecimal so you can just you know hash fa fa fa for gray or whatever right you can you can take sort of web colors and and plug them in which is really cool and they even have themes like you can set up general themes you can use context managers so in a with block you can set a color things like that yeah okay that's neat yeah yeah pretty sweet i might start using it i've looked at colorama and some of the other ones, and they're fine, but it's like, I don't know, it's just painful to say, like, okay, well, I'm going to take this, like, enumerated text value and concatenate it with my string to make it a color.
Starting point is 00:14:35 And I think Colorful is a little nicer. Yeah, I wonder if it's built. I haven't actually tried it. I wonder if it's built on top of Colorama. Yeah, we'll have to look inside. Anyway. Speaking of packages, everybody who works on making a Python package,
Starting point is 00:14:51 they want to add a nice bit of bling, make it fancy looking, right? Yeah, all the extra little blips and stuff. Yeah, so there's a lot of things that make a package look professional or not professional. But there's this article called Five Steps to Add the bling factor to your python package and i thought it was pretty cool i mean it's it's certainly not exhaustive and it's not i don't think it's overly prescriptive but it does talk about a few things that you can do that are pretty sweet and so i'll just run through the five steps real quick so step one you can host your
Starting point is 00:15:19 documentation on read the docs that's right? Proper documentation somewhere with search and all that kind of stuff. Set up continuous integration with Travis CI or, you know, maybe AppBayer or whatever, right? But if you're going to set it up, some kind of continuous integration. And if you're going to run unit tests, you probably want to know what your code coverage is. So you can show your code coverage with code cove. Obviously, if you're going to have a package, if it doesn't live on PyPI, it's almost not real, right? It's unless there's some weird requirement about like, it really has to be set up in some bizarre way that it can't be installed there. From there, it really should be on PyPI, which is great. So add it up there and talks about how to do it. It's surprisingly easy to get your package onto PyPI.
Starting point is 00:16:07 And finally, if you have all these things, you want to have badges, right? This thing supports these versions of Python. Its tests are currently passing or not passing. It has this level of code coverage, all those things, right? Yeah. And one of the things that this highlights for that, I guess I always knew, but I don't think about it very much is all these different services for open source projects. They're free. Yeah. Every one of those. Yeah.
Starting point is 00:16:30 Yeah. But I mean, it's not free for them to run it, but that's cool that all that stuff's just there for open source projects. Yeah. It's really great. Like read the docs is free. They do have ads on there. I'm not sure how targeted the ads are. They're pretty relevant to Python developers, but I do think it's a challenge. I know the Read the Docs guys are doing interesting and creative things to fund it, but it's non-trivial to run it for free for the world. How about Travis CI?
Starting point is 00:16:57 Well, I had talked with Josh Caldaramis from Travis, and since they started out as open source stuff to start with, and they were doing it in their hobby time, and the commercial side is now how they're doing it full time, and they have jobs. And the reason why they maintain the free for open source is because they got their careers from open source, and they want to give back.
Starting point is 00:17:25 Oh, that's really cool. So if I had like a private GitHub repo, I'd have to pay to get CI on it. But if I have a public one, it's free, something like that. Yeah, they have an enterprise drive of CI so that you can use for closed repos or private, not private repos. Yeah, private ones. So what I thought was cool about this is none of those things are hard. None of those things are major, but they all make it, it shows that you care about what you're building. So you're more likely to get contributors. People are more likely to adopt your package, things like that. Also nice to have all these together because I can imagine if I wanted to do any of these, I'd probably spend an hour or so trying to figure out each little bit. Yeah, there's little tips at each one, which is cool.
Starting point is 00:18:02 All right. Well, that's our news for the week, Brian. Anything besides the fact that you're just tooling around Germany? Well, I think I'm doing management training, so maybe I'll finally learn how to become a manager after doing it for many years. But I was working furiously on the book on the plane trip over, and we're still barely on target for a beta for PyCon. I just looked.
Starting point is 00:18:29 PyCon is two weeks away. I can't believe it. There's not a lot of time. There's not very much time. I know. Anyway, I still have to order stickers. It's going to be so fun, though. Yeah.
Starting point is 00:18:37 Yeah. You still got time, but not a lot of time. Not a lot of time. It's going to be tons of fun. So I'm looking forward to meeting a bunch of the listeners there going to be tons of fun so i'm looking forward to to meeting a bunch of the listeners there and hanging out with you and everyone else and uh how about you anything up with you not not too much just thinking about pycon makes me think i gotta get a bunch of stuff ready for for the conference for a booth and things like that so yeah it should be a lot of
Starting point is 00:19:00 fun yeah i can't wait thank you for listening to Python Bytes. Follow the show on Twitter via at Python Bytes. That's Python Bytes as in B-Y-T-E-S. And get the full show notes at PythonBytes.fm. If you have a news item you want featured, just visit PythonBytes.fm and send it our way. We're always on the lookout for
Starting point is 00:19:20 sharing something cool. On behalf of myself and Brian Auchin, this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.