Practicing Python With CSV Files and Extracting Values With "filter()" | Real Python Podcast #66
Key Takeaways
The video discusses practicing Python skills with CSV files and extracting values using the filter() function, along with various tools and concepts such as Excel, pandas, and Bayesian analysis.
Full Transcript
welcome to the real python podcast this is episode 66 are you ready to practice your python skills some more there's a new set of practice problems prepared for you to tackle and this time they're based on working with csv files this week on the show david amos is back and he's brought another batch of pi coders weekly articles and projects david shares an article about functional programming the focus on the filter function the tutorial covers how to process an iterable and extract the items that satisfy a given condition but also covers combining filter with other functional tools and compares it to coding with pythonic tools like list comprehensions and generator expressions we cover several other articles and projects from the python community including excel python and the future of data science a bayesian analysis of lego prices in python why can't comments appear after a line continuation character teaching python on the raspberry pi 400 at the public library a cross-platform editor designed for writing novels built with python and cute and a text user interface which uses rich as the renderer this episode is brought to you by digitalocean's app platform alright let's get started [Music] the real python podcast is a weekly conversation about using python in the real world my name is christopher bailey your host each week we feature interviews with experts in the community and discussions about the topics articles and courses found at realpython.com after the podcast join us and learn real world python skills with a community of experts at realpython.com hey david hey chris good to have you back coming on the show and covering much more high coders weekly stuff yeah absolutely this week got a couple real python things and then kind of a whole bunch of interesting stuff that's leaning toward the project area which i'm excited about yeah again stuff we we kind of keep hitting things that we've talked about before and kind of excited about that too to kind of follow up on some topics we've touched on yeah so what what do you got first so my first one comes from the website infoworld it's by matt assay i think it's how you hey today's last name it's called excel python and the future of data science and i just i've got to put a kind of a disclaimer out there that uh if if you go look at this article there there are a lot of ads and pop-ups so just be aware of that i think they only give you like one free article a month and then you your paywall but it was a really thought-provoking article so if you can get through all that i do think it's it's worth it so the article is about kind of python and or really python versus excel and what the future of data science and python might look like or data science in general and it starts with kind of an interesting tidbit of of information that kind of seems surprising if you think about you know what if someone were to ask you like chris if if i were to ask you what do you think the most widely used tool in data science is what what would you like off the top of your head what would you probably say well i think i think we might even have touched on this before but i think it it probably is still excel yeah it's also like one of the largest databases which is crazy yeah it's definitely like yeah one of the largest databases i think though you know when people hear the word data science they think like a data scientist right like someone who's actually doing data science sure and they're probably like their interaction with excel is probably at this point i mean i don't know this for a fact but i i would venture a guess that that their interaction with excel is something like they've been sent a spreadsheet of data and they need to extract that and get it into something else they might be using python they might be using r they might be using something something else you know this is like a practicing data scientist right sure but excel is being used to analyze data and gain insights from data from people who are not data scientists and so in a sense it's enabling non-technical people to do some data science like activities you know small business owners and even large business owners that uh that don't have a technical background it's very easy or very maybe easing is not the right word but it's it's very i don't know in some ways it's really available like it's the tool that's installed on everybody's machine i have friends that you know work for like a department of health right and you know that's already there and so that's the tool that's in front of them and they make it work you know and which is kind of amazing in some ways that yeah that they can kind of twist it to do all the things that they want to do um it may not be the simplest way to do it you know well but there's a lot of you know it's got kind of a point and clicky kind of interface for a lot of right this stuff you can you know highlight a couple of columns in a in a worksheet and quickly generate some kind of graph or visualization or you know look at look at your data in a different way and start asking and potentially answering questions so in that sense you know you can't say excel is the probably the most used tool in data science and this article talks with kind of interviews peter wang from who's the ceo of anaconda of anaconda python and he talks about his vision for the future of python and the pi data ecosystem it's not about like python versus r or you know some other language like that in his mind it's really about taking on excel and how can we take the power and the tools and in the open source structure of the python data ecosystem and put it in the hands of non-technical people so anyways it's just it's a really kind of fascinating look i thought and kind of thought provoking about you know where where all this is headed and what uh i guess specifically peter's vision for it is i know he's not the only one that has this vision so so it is i think worth a read it's not a technical article it's not a tutorial or anything but really was just kind of like yeah i mean it's time for python to kind of uh tackle this if we want to get those tools in people's hands you know this is kind of the direction we need to be heading otherwise it's just going to stay even though it's you know it's immensely popular the python data ecosystem it's going to stay only in the hands of kind of the trained data scientists and and those people right we keep talking about how people inside of organizations start to develop these superpowers that other people notice them using something like python and you know yeah like think that they have these magical skills now part of that is just getting that hurdle of like your python basics book like you know getting things set up and right going and doing your initial programs and and so forth and flattening that curve is is a goal of real python in general like yeah how can we get people in and using these tools and make things more approachable and that's one big advantage of you know like the talked about anaconda the the distribution of like a whole sort of ecosystem as opposed to it piecemeal there's definitely different approaches on on all that so i i i still feel like yeah we can bend this curve even more so it'll be interesting i feel like we're there though like i feel like it's starting to happen just like in these little steps and so forth some of the other things we'll talk about today with interface tools and things like that so yeah yeah cool what you got so mine is a real python article and it is kind of on a theme um you might remember we had jim anderson on in episode 27 and he was talking about uh preparing for an interview with python practice problems yeah and he you know discussed the process of creating this whole thing and looking at multiple solutions and i think the main idea was we want to give you these problems and then have you think about them and so there's a whole sort of show hide portions of the article where you can kind of decide if you want to see the answer or if you really want to go ahead and work through it before you can do your comparison with it and this follows that structurally in this case he's the focus is on csv files and so it's python practice problems parsing csv files one thing that i got a little tripped up on is i was like looking for the the quote-unquote csv files but in this case it's focused a little differently in the sense that you're starting with the concept of test driven development and if you're not familiar with that this kind of takes you through some of it it also provides a bunch of links to additional articles like we i think we mentioned dane hillard had a really good one recently about test driven development and using pi test which is kind of the tool that's being used here and so instead of you know like full on csv files you're sort of mocking a lot of that up with something called a pi test fixture and the fixtures we might have mentioned that term also this idea of like pre-organized data that you're going to use and then you can kind of predict and already know the results of you know so that your tests can pass so it's a very different approach on the practice problem theme you know not only are you getting to work with how can i easily parse csv files using tools that are built into python but then there's like four sort of scenarios that you're going to get a chance to kind of practice that's funny because we're building off of an excel article right yeah you can export your excel stuff into csv and be right along here so yeah the first problem that's described is parsing football scores this would be the world definition of football of soccer versus the american-centric one and you're writing a program that's going to take the file name on a command line and then process the contents of the csv the program's gonna determine which team had the smallest goal differential so like between goals that team scored versus that were scored upon it and so those two numbers are like subtracted and they're taking kind of the the overall value to see you know which team had the smallest one so that they're they're they were closest together those own goals versus uh goals against them so it's kind of interesting just kind of the the math there isn't super complex but you are still going to need to go through and kind of parse things line by line and so forth so i'm not going to spoil it because you should work through these problems and then in there you're getting the problem solution that the real python team went through and next one is about weather data really popular at this moment because everything's just crazy heat wave the two of us are still kind of on the western part of the u.s and we're sweltering away here that one is about taking the average days high and low temperature and comparing them your program should determine which day had the highest average temperature so that one you're kind of working with just a slightly different set of data and kind of going through it then you do a refactoring figuring out how to make all these things a little more efficient by maybe reusing a lot of the csv parsing that you were doing which is a you know structurally something you should eventually kind of think about you might come up with a simple solution initially but now you're going to kind of come back and then think about okay well you know how could i i have a solution that can reuse parts across multiple other things and then the last one is instead of using some of the built-in python csv tools you're going to do csv parsing with pandas we've had actually a bunch of really interesting courses come out based around pandas lately and so i'll provide links to those uh if you're looking for some additional um skills to work on and one was the gradebook project recently came out and that one has a lot of really kind of fun tools that you're learning to practice and use there yeah so yeah it's another version of what we were talking about before of let's practice your python and here we're giving you a bunch of things to for you to get a chance and then you can kind of reveal these solutions as you go along and check how you did yeah exactly it's a really neat format i think it's not a tutorial i mean i guess you could kind of consider the solutions yeah in some sense because he does jim does you know explain the solutions which is kind of funny that you know it's it's a rare thing on real python where the the bulk of the text in this article is hidden when you first it looks small first look at it it looks small and then you open you open the like the solution box and and you know it's got a full explanation in it and uh walks you through everything and some some of them have multiple solutions for you to to look at but uh yeah it's a really it's a really neat format and i think that you you hear people talk about this idea of you know getting stuck in tutorials and i i think that it's there's a need in general for the different kinds of content you know that it's yeah and you know that goes beyond the tutorial to like okay this is giving you a chance to you know here's a problem you can practice it and then you can compare notes with uh one or two solutions that we've come up with that are fully explained you're actually getting to do something yourself so it's uh yeah it's a really neat format i really like it i think jim does a great job with these like he said it's the second one he's he's done at this point i think i hope that we'll have uh have more coming coming down the pipeline yeah it's funny i have a question for you um do you when you approach a tutorial or like maybe a book that's filled with these types of projects that they're kind of walking you through step by step do you ever try to go off in advance and try to do the thing before you read the explanation you ever attempt that on your own uh like if i'm actually reading a tutorial yeah you're like oh i see what they're going to try to do here let me let me see if i can hack it out myself you know actually i don't think i've ever really really done that usually if i'm following a tutorial i'm just going through it kind of step by step and and and following along i have done quite a bit where like you get done with the tutorial tutorial and then it's like okay what could i do to kind of like build on this you know where could i take this yeah but no it's uh that's interesting i don't know what that says about me but uh no i haven't really really done that i i've recently started to do that just occasionally like i'm like okay i see what they're trying to do like i see a pattern that this author has and they like to do this and i'm like i think they're gonna try to do this again so i'm gonna go try to work ahead yeah and see if i can kind of solve it a little bit and i'm not going deep far ahead because i may not have the domain knowledge but i can kind of like start to suss some of it out and so i think you're your solution for like kind of making a tutorial a little fresher of like all right well you know how can you expand or expound upon this thing of that you're created is kind of interesting and then you know like my idea of like going ahead the other one that i've done that has been interesting is if it's like a video tutorial often i will watch all of it um maybe because i'm in a different circumstance you know yeah you know right a treadmill or something or whatever you know and so forth and so i try to keep all of it in my head yeah and then try to go do it oh yeah i've done that a lot yeah where like you read something or watch something and you don't necessarily follow along exactly yeah like with it but you and then you go back and you try to recreate that yeah i've done that i have done that a lot and actually in the python basics book we actually have uh some exercises okay in some chat in some chapters that like every section has exercises more like there's like a couple of rare sections that don't have exercises but but there are a couple of sections where you kind of like build something and one of the exercises is to go back and try to rebuild it without looking at anything in the in the chapter nice and just see like what you've retained like what and if you don't remember something try to try to do it like try to solve it on your own and so yeah that's a really great uh learning technique i like that yeah you know so there's a lot of ways you could kind of not make it be so step-by-step it's i guess what i'm trying to imply if you're afraid of like you know letting go for a minute and trying some of the stuff out there's a there's you know a handful of techniques that somebody could kind of try to expand upon their their step-by-step tutorial habit [Music] digitalocean's app platform is a new platform as a service solution to build modern cloud native apps with app platform you can build deploy and scale apps and static websites quickly and easily simply point to your github repository and let app platform do all the heavy lifting related to infrastructure get started on digitalocean's app platform for free at do dot co slash real python that's d o dot c o slash real python [Music] what what do you got next next one i've got comes from austin rockford i i believe or maybe it's roachford i'm not sure okay so this it's a fun article called a bayesian analysis of lego prices with python with pi mc3 and perfect for you uh yeah i don't know how much we've talked about my lego obsession on this anybody who follows you on twitter anyone follows me on twitter they've seen me post like the the you know my builds and stuff so this immediately caught my attention it's you know math and stats and lego in python so it's like you know perfect right yeah confluence of things that uh that i that i enjoy it's it's a really interesting article so and it's actually a a second in a series of posts that uh that he has written analyzing lego pricing data scraped from the website brickset.com and in the first post he gives like an empirical analysis of whether or not a lego set it's a in particular it's a star wars set like whether or not it's a fair price because when he was looking at it to order it it was like 70 bucks and it's not a big set it's 663 pieces which for a for a lego set is not massive and he thought wow that seems a bit steep so he tried to answer this question like what what is a fair price for this so he's got this kind of empirical analysis that he's done and then in this article he does a much more statistical analysis and it is very technical and he does some explanation of some of the math that's going on but not a lot so it is assumed that you have you know kind of a stats background but it's full of code and really walks you through walking through a bayesian analysis of something which is really really neat and it also uses a an interesting project called pi mc3 which we featured in pi coders we haven't talked about it on the on the podcast it is a tool for doing probabilistic programming in python so they describe it as it allows you to write down models using an intuitive syntax to describe a data generating process it's just kind of neat it was the first time you know i found i found this project and was like this looks really cool and you know i've i've thought about probabilistic programming in the past i've never done much of it but it was neat to see a python package and this is the first time that i came across an article or a project that was actually using it so i thought that was kind of neat it's it's a it's a really cool article like i said i really like finding these examples of kind of an end-to-end analysis so you kind of get a sense for like you know what is this person like what is their thought process how are they how are they thinking about tackling this problem what kinds of things are they looking at do they do they shift like do they find something that surprises them that sort of you know shifts some kind of hypothesis and and they you know have to kind of change the way they're approaching it things like that and yeah so this is just a really really nice walkthrough of an into an analysis of whether or not this particular lego set is fairly priced and what's interesting is he in particular he's looking at a star wars set and i think anyone who has purchased lego yeah you know of like official lego realizes or knows that the spot not sponsored but like the what's the what's the word the sets that are licensed the disney license thank you that's the word i'm looking for the license sets uh are generally more expensive than than the non-licensed sets and so yeah it was like harry potter star wars if you look at it on like a brick a brick by brick comparison you know you might be paying several cents more for you know a small brick in a license set than that same brick would cost in a non-licensed set so there's like kind of just interesting factors that you have to take into account with all of this and so yeah it's just a really fun article it's got lots of cool uh examples of plots and you know there's lots of scatter plots and talking about you know how he how he's using those scatter plots which i think is another kind of neat thing you see you see a lot of tutorials that are like here's how you you know make a scatter plot in in matplotlib or seaborn or whatever or here's how you uh you know look at it how's how you generate a histogram but unless you've taken a statistics course or even not just a statistics course but more of like a you know mathematical modeling course or things like that it's not always clear how you're supposed to actually use those plots or like when you lay out the axises and yeah yeah so yeah it's it's a fun fun article and yeah if you like stats and you like lego and you like python you'll probably like like the article you'll be down for this one yeah yeah yeah cool all right well my next one's a real short one and it built on one that we covered last last time we were talking about black and white's recent little blog post he had that was about the sad face d-dent yeah and i feel like it's very much related to that in a sense that how black is formatting things within brackets you know again it could be parentheses squares or curly or whatever but the idea that they're kind of given line by line and so forth and so this is a stack overflow question thread and it starts with why can't comments appear after a line continuation character if you're not familiar with a line continuous character it's in as you're writing something in python if you are needing to i don't know this whole line is going to go past let's say you've set up your editor at like it should wrap at like 80 i think is common but i think even under that might be more common like characters across um and so you might decide all right at this point is where i feel like it should break and so you put like a slash to indicate that and so this person was like well if i put a slash there kind of like maybe a little earlier i also might want to put a a comment and python doesn't allow for that it it doesn't it can't parse that like there's really not anything you should put after the line break and so the most popular solution that ken came up was well you should probably uh if you want to try to do something like this you want to go line by line breaking something down similar to how we were just talking about it was done inside of black in that case then you probably should go ahead and put things in a pair of parentheses and in that case you can you kind of white space again doesn't matter which is really nice and you can actually just drop in comments with a hashtag inside there to uh you know normal inline comments that you would use in python you could put them right inside and yeah it's it's pretty slick and it again some of the advantages of doing it that way you know follow from that other article you know the sort of the consistency the readability sort of the developer efficiency which we mentioned like the idea of minimizing diffs and you probably have seen things like this before like i think we mentioned that you know not only can it be that you know the arguments or the values in the list or making out the items in the dictionary or what have you that you're kind of breaking them line by line but one of the other ones that i that kind of is related is we've been talking about pandas a lot off and on here the idea of like chaining yeah commands um which is something that i used to practice a lot with r that has this pipe kind of operator thing that would allow you to like take one process and then the result of that do this and then do this and inside pandas you can do a lot of that with just a dot and continue on and that would be a really common place where you'd want to drop a note like what are you doing here with this next step you know it's like okay i'm going to go ahead and i'm going to sort and then i'm going to sum and then i'm going to do this and i'm going to do this and then instead of those being like all separate kind of messy looking calls one after another you could have it sort of stacked up and and have the dots all in alignment and it's you know it's a pretty slick way to do it and i definitely have been seeing that more often but the problem is if you want to accomplish that you probably if you're gonna you know break things out line by line like that you would use again parentheses to kind of uh sort of make that a whole block of code together right it's a technique that i think gets overlooked in a lot of like tutorials and a lot of you know when you're when you're learning python this you know using parentheses it's it's a it's a different kind of use of parentheses it's basically creating like a block where kind of everything in that block is sort of you can you can you can move things around the way you want you can put things on different lines and at the end it's basically just going to you know snap everything together and sort of suck all the white spaces right yeah in a sense like that's one way to think about it and it also works for strings which is right where i've used the two most common places that i've used this is like in pandas when you have to chain a bunch of methods together on like a data frame and and then also when i want to write like a paragraph of text in in my code that doesn't fit on a single line and i don't want you know you could use like the the triple quoted strings which you see for like doc strings but those preserve white space so you have to be like if you get to the end of line you hit enter well that new line character is in there like it's in any indentation you do like it it just preserves all the white space in the string so if you want to not preserve the white space you want it to be one continuous string you can do this and it's like like an implicit concatenation basically you don't have to use the concatenation operator things like that so yeah it's just a really it's a really neat technique something to be to be aware of and it can really help make your code look a little bit nicer yeah the readability is like a huge factor of it i think you know like yeah especially if you're gonna if you're gonna chain things you know chain object methods or you're gonna like you said do something with text or you want to you know have comments next items and so forth it gets parsed in a very different way which is great so what do you got next next one i've got is another real python article from our good friend leodonis poso ramos the probably at this point the most prolific real python author is super cool yes and this one's called python's filter extract values from iterable so this is all about the filter function which is one of the built-in functions in in python and it's a very in-depth thorough discussion on what filter is so i think we've talked about well i know we've talked about in the past we did map we did map yeah and i know we've talked about like functional programming styles so this kind of falls into absolutely there's like this map filter reduce sort of like trio of functions and we've got the reduce one i believe that one has been published yeah we've got the the one for reduce we've got the one for map and now we have the one for filter so we've got that trio covered and it's it's a similar i guess structure to the other ones you know you get introduction to kind of what the functional style is and uh understanding like what a filtering problem is so let's say you've got a list of numbers and you want to extract from that list only the positive numbers or only the even numbers or you know i don't know numbers that are prime or multiple of three or some something like that you know it's very common this is a very very common problem you know the numbers example is also common but this shows up in many many different ways you need to filter some kind of list or some kind of sequence or or iterable on some kind of condition so filter is one way to do that and you get a full walkthrough of you know how you use filter to solve those kinds of problems but then there's also a discussion of combining filter with other tools so you get to see how kind of map and filter can work together how you can combine filter with reduce and there's also a discussion of uh a different kind of filter function from the iter tools module called filter false which is kind of doing like the inverse of yes okay so the filter is like i'm going to pull out all the elements of some iterable for which something is true and filter false does the opposite it pulls out all the elements in an iterable for which something is is false so that is a variant on that you get to see that and then there's a discussion about pythonic style and you know should you always use filter when you can there's certainly nothing wrong with that but you can also achieve the same thing in a lot of cases with a list comprehension and you know you can argue one way or the other is that more readable is it less readable you know list comprehensions comprehensions in general one of those things that could be very confusing for beginners especially if you don't come from like say a more mathematical background you know for me when i first saw a list comprehension it was like this looks exactly like step builder notation that we use in mathematics all the time and so it was very easy for me to wrap my head around that because i i'd seen a very similar style and a very similar structure and had already gotten over the you know the learning curve for that but yeah so it just talks about you know the difference between those two styles and how you would rewrite some of the things you've seen in filter using list comprehensions things like generator expressions which is like a generator comprehension in a way and things like that so yeah it's just it's a like i said it's very thorough kind of covers all the bases and you know map filter reduce it's one of those things it's not specific to python you see these functions with the exact same names in in many different programming languages yeah and it's just one of those things that at some point uh you want to be familiar with this stuff just to to know that it exists and and when sometimes it might be better to use something like that it makes me think about this course that we have coming out soon about inner functions oh yeah the idea that python is sort of a jack-of-all-trades type of language you know it's trying to do all these different things or at least allowing you to have access to them so you know one of them is obviously as we've discussed now functional programming you can approach python in that way if you want you can approach it with all these kind of different ways of like you know what makes sense do you want to do object oriented do you want to do you know functional or do you want to do these other different styles which i think is powerful it can be a little you know confusing because there are so many options yeah but i think that's that's kind of a a unique you know kind of powerful thing about python and and something that i did not understand initially like i felt like it was very easy to to be lured into one area or another and and not not realize that you know you know these are people that are coming from java and they really want it to be like this and these are people that are coming from this and they really want to be like that you know right hey kid come over here check this out you know like okay yeah so suddenly you're like in a different camp of of uh style you know which is interesting exactly and it does kind of seem you know it like some of this stuff kind of goes against like the zen of python the there's one that says something like you know there should there should be one and preferably only one way to to do something and you look at something like filter or map and it's like well i can i can i can do these multiple ways uh at least to you know replace it with uh with a list comprehension or something like that but but at the same time you know it's you know it's just the nature of of languages to be completely honest right like they're going to grow over time as more and more people use them they're coming from different backgrounds and you know it's true of of not just programming languages but also human language it's uh it's just a natural uh thing but it's something like mapreduce filter it's like this it's sort of like this iconic thing that you find in in so many different languages that it just makes sense to have it uh in in python yeah that totally makes sense [Music] this week i want to shine a spotlight on another real python video course it covers the types of things a python developer should know when starting to work with javascript it's titled python versus javascript for python developers the course is based on an article by bartosz zinski and in the course christopher trudeau takes you through where javascript comes from and where it's used how javascript's type system is different from pythons how to write functions in javascript and the two ways of creating objects in javascript javascript's general language syntax along with surprises and behaviors in javascript that python programmers wouldn't expect i think it's a worthy investment of your time to learn how to navigate the differences between two of the most popular programming languages if you want to share your python code and projects with others it's highly likely you want to do that over the internet and it would be helpful to be prepared for what you can expect when working with javascript all real python video courses are broken into easily consumable sections and where needed include code examples for the techniques shown the lessons have a transcript including closed captions check out the video course you can find the link in the show notes or you can find it using the newly enhanced search tool on realpython.com [Music] my next one is kind of taking off from a project i had mentioned i don't know probably more than six months ago and it was about the raspberry pi 400 the sort of packaged version of the raspberry pi that is sort of a keyboard with all the ports right on the back of it so you can just plug it into an hdmi monitor or a television if you want it kind of reminds me of the commodore 64 or some of the early computers that i had right where i just attached it to a tv you know which uh you know seems like ages ago but i think the computer itself is around 70 u.s something like that yeah but this this guy don watkins he's listed as a correspondent for this site um opensource.com and he has two different articles that i kind of wanted to touch on the first is i guess the core one is how do i is called how do i teach python on the raspberry pi 400 at the public library and i'll touch on that a little bit more but one that was associated with what was his review of the raspberry pi 400 and he was reviewing it as the 100 package so it came with like an sd card came with a mouse came with a power supply uh came with like kind of all the things you need and then i think one of the most interesting things that it comes with is it has a manual and he pointed that out and i was like yeah you know you buy a mac today or you buy a pc today and there is no book i mean it's like literally like you know maybe like some kind of like warnings or other like little minor things that maybe needed to be required to be included but i remember getting manuals with computers you know and that's something that i think is vastly useful in certain circumstances especially something like this where it's a inexpensive computer and you might be using it in a circumstance where the person maybe has never had a computer or you know i just talked to marlene mongami in the last episode and we were talking about you know how in zimbabwe she's trying to set up these classroom situations and so forth and i thought about this computer and we had talked about books and the idea of like giving a kid who may not be able to take the computer home they may not you know have a monitor they might have all these other tools but maybe they could take home the documentation and they could read more about it and in this case it's it's more than a manual it's like you know it has projects and other kinds of places to explore so it's you know this is sort of like documentation that seems to be missing in so many things these days that that i think is kind of neat that that that's included in that way uh so anyway so i like that review of it and then his review also kind of really focused a lot on you know hey can i set this thing up to to be with a webcam and and get it to be you know something where like remote learning could be used also you know based upon the last year of school yeah and so forth and so he finally did get like a logitech webcam to work with it and most video conferencing stuff after a little bit of wrangling he was able to get them going the one exception was zoom which is interesting i don't know if that's a limitation of the version of linux but anyway uh he was able to get like google uh is it meat now i always get the names wrong but anyway yeah and a couple other ones that were out there so that's a neat review of it and then the the focus of the teaching in at the public library is that he had been wanting to get back to teaching really you know after the last year and wanted to figure out a way to kind of give back and and get back to teaching actual python in a sort of situation like that so he was able to to work with a library in new york and get them you know in a kind of a community based group to kind of get a little bit of funding and they were able to buy like five of the computers and then some inexpensive monitors i was just trying to look at like how much like a like a simple vga flat screen monitor is and it's unfortunately close to the price of the computer but generally you know like around 80 to maybe 120 depending on the size you want but anyway that's something that could be you know reused and and again if you have a raspberry pi you can plug it into pretty much anything with an hdmi connection and yeah you got a display for it so most tvs today his goal is to really just get people working with it and so he he's it's a fairly short article but he really liked the idea of like how easy this was to kind of get going and set up he talks about using it with the mu python editor yeah which i know that we've talked about in circumstances with sean and kelly the teaching python podcast and they're sort of fans of that editor too it's very popular for you know things like circuit python which i'm going to be focusing on soon and then he mentioned a couple books that he was able to get teacher kits to code and python for kids and yeah and so then you know he what's really cool is you know he was able to work with like the turtle module and get them going i know that's something that we have not only a good article on but a nice video course inside there and at the end of it you're creating a little game which is which is pretty fun for kids to kind of get them going so yeah it's a neat set of articles i've had a couple people reach out and wonder you know what are other resources that we have that you know can help people get into the not only you know teaching of python but some of the resources that are available to to kind of get set up on their own to replicate something like this and you know it's a fairly inexpensive footprint you know for the the price of like a modern uh macintosh computer you could get five of these computers and their monitors and right yeah you know and they come with books and all that sort of stuff and for teaching python you know it doesn't need to be this over large set of uh things it's like the the goal is more i don't know i think about that sometimes like you know like if the if the computer is kind of more centric toward doing you know programming and that sort of stuff like could that be less of a distraction not saying that you can't you know go on the web and so forth with these computers i'm just saying it's less of a focus in some ways right yeah yeah these i mean it doesn't even come with the screen it only comes with a keyboard yeah so like it's definitely not like the idea is not that you're going to like consume content on this device it's clearly more like creating or or uh you know learning but yeah i mean it's just one of the things that struck me when i read this article was that he had been uh he being dawn the author had been wanting to do this you know this community class at the at the library and then we you know we have the the pandemic and he's in new york and i think you know things got really really you know i don't it says he's from franklinville on which i don't know where that is but but you know new york got hit really hard there early on in the yeah and the pandemic here in the us and you know things got locked down and and he really wanted to get back to this and i think he mentions in the article that you know he had been searching for you know someone to kind of sponsor this and you know help pay for some of this stuff but in the end he was able to just kind of self-fund it like he was able to just buy these computers for the the people that wanted to take take the class the barrier to entry is in some ways or at least you know the financial barrier to entry to all this stuff is in some ways i think the lowest it's ever been in the history of it's kind of computing and it's yeah it's just really incredible what uh what you can do and from the perspective of someone who's teaching that even he was able to just fund it himself like that is just kind of mind-blowing to me it's like hey i'm going to have this class students and you know what i'm just going to buy them all computers and it wasn't that long ago that would be a lot of money and right uh and now he was you know it made it affordable and within his reach to even just you know donate and contribute to that so that's that's really amazing and and yeah i'm with you you know i think that if you're just learning python you know you don't need you don't need a macbook pro you don't need the latest whatever right you can use just an old laptop with uh with linux on it and the beauty of you know python being open source you know now the open source operating systems and everything i mean it's just yeah it's just kind of mind-boggling i mean i remember i remember when my family got our first computer and i remember like just you know that was it was a privilege to have a computer yeah at that time yeah and and i remember even you know past that going to the computer shop like we would go get it repaired and i'd go into the computer shop and look at the the computers they had in there and you know it was like these computers the raspberry pi 400 is probably more powerful than those computers and those computers were like two thousand dollars and i remember just thinking like man would it be so cool to have something like that but oh it's so much money like we'll never we'll never have anything like that now it's like you know this 70 dollar computer yeah that's what price is more powerful you know a family going out to dinner or what have you you know like depending on where you go yeah you know it's kind of amazing yeah well that kind of was leading us into projects as we went sort of building on top of it so what's your project for this week mine is this really cool project that actually dan dan bader found and and he was the one that sent it into the pie coders you know something that we should talk about i took a look at it i've not actually played around with it but but it just is a really cool little project it is it's called novel writer it's a plain text editor designed for writing novels assembled for many smaller text documents it's got a minimal formatting syntax inspired by markdown it allows you to add metadata for comments a synopsis and like cross-referencing things and this is again one of those projects where it's not so much like i think you should use this as much as like man go check out this this repository it's it's python they're using the uh cute uh q5 gui framework so if you're looking for a good example of a of a gui program in python like this is this something to go to check out it's got a lot of cool little features and they've also got the repositories been set up it's got tests it's got they're using i don't know if it's circle ci but you know it's got continuous integration it's got you know the packaging stuff it's got a setup.py and setup.cfg file so it really you know and code coverage as well on on the on the testing side so you can see how much of the code is actually being executed when you run your tests so it's really kind of the full thing like if if you want to see a modern example of a gui application in python it's a really cool repo to check out nice yeah so so mine is building off of a project that we mentioned a couple times which was called it's called rich it's from will mcgoogan you know we had a post back in february or one of the other things we were talking about of a group of people taking rich and you know again it's a library for rich text and colors and formatting inside of the terminal and in february this group and he wrote about it in his own blog they built a terminal dashboard using rich and and that one was for like uh it was showing like github in real time you know using it to kind of render it out he was very intrigued by these people doing that and so he kind of went and started focusing on it and after that he just announced his his own version of that it's called textual yeah and it's a text user interface a tui and it's a built with rich as the renderer underneath it and it's pretty slick what he's built and he gives a nice demo of the dashboard and sort of what's happening and he has added like hover you know mouse hover focus and scrolling across these separate windows key binding so that you could type a key and one of the textual little windows will pop in or pop out appearing and disappearing inside of like a larger layout so you could kind of like dismiss something or you know look check another area and so forth yeah and then uh he's also been focusing on just really getting that scrolling right and like indicators and things like that so it's it's neat to see this uh you know text-based uh ui sort of expand upon it i expect to see more what we would have called uh command line interface tools start to maybe use this as a way to kind of you know expand on it and give you a little more of a ui than just simply text coming into it and one thing i wanted to mention is that i i was looking at rich and and then the repo for that and i got to near the bottom of it and this is something i'm going to be talking about a little bit more rich is used by so many different tools yeah just because people really like you know what it can do as far as making you know the terminal experience a little more enjoyable and and the whole like there's like this whole realm of of uh ripple replacements which i know you've been working on yeah that use tools like rich underneath it and so it's you know become kind of one of these very useful tools across the board and it's actually part of the tide lift subscription for enterprise and so he talks a little bit about that and i recently spoke to some people from tide left and i'm hoping to have them on the show soon kind of explain you know what's going on there and again that is one of these focuses not only on you know funding of open source and keeping open source going but also kind of a security thing which i'm also talking to dustin ingram really soon to talk about his talk at uh pycon and sort of like what do you need to be aware of as a developer as far as security and also as a you know python user and uh and i feel like the tide lift thing kind of builds on top of that too so it's going to be a fun set of conversations kind of building on all those ideas to you know pay attention but it's it's funny like how you know how much open source it builds on top of you know the shoulders of these other packages and so forth and rich is definitely in there so it'll be interesting to see what happens with textual if they uh if it gets the same kind of embrace yeah yeah it's uh i'm just looking at it now it's the used by on the github repository if you scroll down a little bit on the right hand side you see used by and it's uh 3800 3800 of the repositories list this list rich as a as a dependency
Original Description
Are you ready to practice your Python skills some more? There is a new set of practice problems prepared for you to tackle, and this time they're based on working with CSV files. This week on the show, David Amos is back, and he's brought another batch of PyCoder's Weekly articles and projects.
David shares an article about functional programming with a focus on the "filter" function. The tutorial covers how to process an iterable and extract the items that satisfy a given condition. It also covers combining filter with other functional tools, and compares it to coding with Pythonic tools like list comprehensions and generator expressions.
👉 Links from the show: https://realpython.com/podcasts/rpp/66/
We cover several other articles and projects from the Python community including, Excel, Python, and the future of data science, a Bayesian analysis of Lego prices in Python, why can't comments appear after a line continuation character, teaching Python on the Raspberry Pi400 at the public library, a cross-platform editor designed for writing novels built with Python and Qt, and a text user interface with rich as the renderer.
Topics:
- 00:00:00 -- Introduction
- 00:02:29 -- Excel, Python, and the Future of Data Science
- 00:07:50 -- Python Practice Problems: Parsing CSV Files
- 00:17:09 -- Sponsor: Digital Ocean's App Platform
- 00:17:45 -- A Bayesian Analysis of Lego Prices in Python With PyMC3
- 00:23:02 -- Why Can't Comments Appear After a Line Continuation Character?
- 00:28:40 -- Python's filter(): Extract Values From Iterables
- 00:34:57 -- Video Course Spotlight
- 00:36:24 -- How I Teach Python on the Raspberry Pi 400 at the Public Library
- 00:46:23 -- novelWriter: Cross-Platform Editor Designed for Writing Novels Built With Python and Qt
- 00:48:02 -- textual: A Text User Interface With Rich as the Renderer
- 00:54:58 -- Thanks and goodbye
👉 Links from the show: https://realpython.com/podcasts/rpp/66/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Real Python · Real Python · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
A better Python REPL – bpython vs python interpreter
Real Python
Introducing large-type.com – A Utility Website
Real Python
Reading Hacker News Without Wasting Tons of Time
Real Python
Forward References and Python 3 Type Hints
Real Python
Using Sublime Text as your Git Editor
Real Python
Python Code Linting and Auto-Complete for Sublime Text
Real Python
Make your Python Code More Readable with Custom Exceptions
Real Python
Write Better Tests with Sublime Text's Split Layout Feature
Real Python
How to Use Sublime Text from the Command Line
Real Python
Rename Variables with Multiple Selection in Sublime Text
Real Python
Sublime Text Settings for Writing PEP 8 Python
Real Python
Write Cleaner Python with Sublime Text's Indent Guides
Real Python
Sublime Text Whitespace Settings for Python Development
Real Python
Function Argument Unpacking in Python
Real Python
Python Code Review: Debugging and Refactoring "Conway's Game of Life" + Automated Tests
Real Python
Using "get()" to Return a Default Value from a Python Dict
Real Python
A Python Shorthand for Swapping Two Variables
Real Python
Python Code Review: Refactoring a Web Scraper, PEP 8 Style Guide Compliance, requirements.txt
Real Python
Click & Jump to Test Failures from the Command Line (iTerm2)
Real Python
Setting up Sublime Text for Python Developers
Real Python
Sublime Text + Python Guide Overview
Real Python
Python Code Review: Adding Pytest Tests to an Existing Python Web Scraper
Real Python
Type-Checking Python Programs With Type Hints and mypy
Real Python
A Shorthand for Merging Dictionaries in Python 3.5+
Real Python
Python Code Review Flask Web Security Tutorial + Virtualenvs, requirements.txt
Real Python
My Python Code Looks Ugly and Confusing – Help!
Real Python
Setting Up a Programmer Portfolio/Developer Blog – How To Get Started
Real Python
Do I Need a GitHub/GitLab/Bitbucket Profile as a Developer?
Real Python
Programmer Portfolio – Example and Walkthrough
Real Python
How to Get Your 1st Speaking Gig at a Tech Conference
Real Python
How to Build Your Public Speaking Skills as a Developer
Real Python
The Object-oriented Version of "Spaghetti Code" is "Lasagna Code" ?!
Real Python
Setting up Sublime Text for Python Developers – Lesson #1
Real Python
Cool New Features in Python 3.6
Real Python
"is" vs "==" in Python – What's the Difference? (And When to Use Each)
Real Python
Emulating switch/case Statements in Python with Dictionaries
Real Python
Python Function Argument Unpacking Tutorial (* and ** Operators)
Real Python
What Code Should I Put On My GitHub/GitLab/BitBucket Profile?
Real Python
A Crazy Python Dictionary Expression ?!
Real Python
String Conversion in Python: When to Use __repr__ vs __str__
Real Python
Method Types in Python OOP: @classmethod, @staticmethod, and Instance Methods
Real Python
Optional Arguments in Python With *args and **kwargs
Real Python
Python Context Managers and the "with" Statement (__enter__ & __exit__)
Real Python
Installing Python Packages with pip and virtualenv / venv
Real Python
"For Each" Loops in Python with enumerate() and range()
Real Python
Python Code Review: LibreOffice Automation and the Python Standard Library
Real Python
Managing Python Dependencies With Pip and Virtual Environments – Lesson #1
Real Python
Python Tutorial: List Comprehensions Step-By-Step
Real Python
Leveraging Python's Implicit "return None" Statements
Real Python
What's the meaning of underscores (_ & __) in Python variable names?
Real Python
Python Data Structures: Sets, Frozensets, and Multisets (Bags)
Real Python
Writing automated tests for Python command-line apps and scripts
Real Python
How to find great Python packages on PyPI, the Python Package Repository
Real Python
Immutable vs Mutable Objects in Python
Real Python
PyPI vs Warehouse, the Next-Generation Python Package Repository
Real Python
pep8.org — The Prettiest Way to View the PEP 8 Python Style Guide
Real Python
My Experience at PyCon 2017 in Portland
Real Python
Pylint Tutorial – How to Write Clean Python
Real Python
"Reverse a List in Python" Tutorial: Three Methods & How-to Demos
Real Python
Python Refactoring: "while True" Infinite Loops & The "input" Function
Real Python
More on: Prompt Craft
View skill →Related Reads
📰
📰
📰
📰
The no-code AI business stack that earns $5k/month on autopilot
Dev.to AI
The Future of QA: AI-Powered Test Automation Explained
Dev.to · Chaithrika Gummadi
Virtual Staging the Smart Way: AI-Powered Furnished Rooms from Raw Files
Dev.to AI
Why 60% of Real Estate Agents Using AI Are Wasting Their Time
Medium · AI
🎓
Tutor Explanation
DeepCamp AI