Configuring a Coding Environment on Windows & Using TOML With Python | Real Python Podcast #122
Key Takeaways
The video discusses configuring a coding environment on Windows and using TOML with Python, covering topics such as Python release management, Django development, and configuration file formats.
Full Transcript
welcome to the real python podcast this is episode 122. have you attempted to set up a python development environment on windows before would it be helpful to have an easy to follow guide to get you started this week on the show christopher trudeau is here bringing another batch of pie coders weekly articles and projects we talk about a real python tutorial for configuring a windows coding environment the guide contains valuable suggestions best practices and powerful coding tools it also covers how to use a package manager a new windows terminal powershell core and a program to manage multiple versions of python christopher covers another real python article about using tomml in python tamil is popular as a configuration format for building and distributing your own packages we discussed how tomel parsing will be added to python standard library in version 3.11 we cover several other articles and projects from the python community including technical writing for developers a news roundup saying goodbye to obsolete python libraries uncommon uses of python in commonly used libraries a prettier ls and a project for advanced hot reloading python 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 christopher welcome back hey there all right so we're going to start out with some news this week i kind of left it all in your lap to do this week so um yeah that's all right it's summertime what else do i have to do yeah sure a couple of quick hits start out with uh python310.6 is out so that's a bug fix release the biggest part of it is there were a couple security fixes in it one affecting the built in http server there was an exploit and the other was some memory being used after it was freed in the underlying engine so that's why you write python instead of c so that you don't have to worry about that kind of stuff yeah nice so core developers worry about it you don't yeah and then uh following a couple days just after that 3.11 release candidate one came out i've also got some good news on that a few podcasts back we were talking about the fact that there might be a delay yeah it looks like they're targeting october 3rd so they must have got over whatever it is they were worried about and solve the problems nice so looks like they're on time which is nice are they they're not considering this a cursed release because that was like the the ongoing i think you're not supposed to say it out loud right i think i think you may have just cursed it right there so we'll see what happens all right and then the second bit was django four one went gold so it's continuing on with some changes in the four line adding a bunch of asynchronous capabilities so this time they've added async to the orm so for the high performance crowd that should make a bit of a difference right and then the part that i'm looking forward to is they've changed how form rendering is done it used to be done with some string concatenation and now it's built on the template engine and this is a weird little devil in the details thing but when you get into crafting your forms you can now use the engine the way other parts of your templates were used so there's some potential there that may make particularly dealing with things like bootstrap and some of that easier cool that sounds good it's good to see the async stuff kind of improving also yeah it's it's a slow steady kind of chipping away at the problem yeah the last one i had here unfortunately we keep talking about this so i just keep bringing it up but just let people know it's out there but there has been another set of malicious packages discovered on pi pi 10 of them this time a couple of them are actually looking in your local storage for tokens passwords and cookies so this isn't just the aws key things that we've talked about in the past and they're starting to get more sophisticated a couple of them that are pretending to be other packages have copied the entire home page and like the graphics and everything so that if you're looking at it quickly it looks like exactly what you're expecting which makes it a little harder to tell the difference so a little trickier yeah and i guess just sort of a shout out to the folks at checkpoint who keep scanning this stuff and getting it taken down because you know it's uh it's unfortunately it's a little bit of a game of whack-a-mole but somebody at least is wielding the hammer so good to know that we uh have some people there paying attention but also that's a little spooky that they're spending so much effort to actually remodel the web pages and make it be more attractive i have a little tiny thing on that front this is an article that kind of related it's from techcrunch and the stories by axe sharma the title of it is protest where on the rise why developers are sabotaging their own code so i'm just going to leave it as a news thing but it kind of hits on one particular person that we didn't focus on last time when we were talking about the two-factor thing that was being added to pi pi for the top one percent well his project fell on the top one percent and he had his own sort of version of protesting it in this case he really didn't want to have to do the extra stuff was mad you know like i do this free open source thing why do i have to add this extra stuff just for corporations and blah blah blah what the story is really interesting gets into is that it then becomes into a different form of protest yes there's other people protesting big corporations using their stuff and open source but there's actually a whole bunch of devs that are using their software to sort of protest russia and that's very interesting and so it's very like localized kind of stuff that's happening with it with either messages to the russian people about ukraine or some other kinds of things that are doing their own active protest in that way so interesting article about that and weird you know with open source how things can be used in different ways so something to kind of keep an eye on i thought it would kind of fit in that theme this morning right cool that takes us right into topics so what's your first one so i'm starting this week with a real python article by gerard hill long-time contributor and somebody i might be working with shortly as python311 sneaks up on us if uh the pattern continues this article is actually a bit of a preview topic for 311 it's called python and tamil new best friends so i don't know if you've ever looked around and said what the world needs is another configuration language uh but tom preston werner did and the world got tommel so tamil is short for tom's obvious minimal language and is a simple to parse configuration language supported by a wide range of programming languages c c sharp c plus plus java javascript swift python of course and a whole bunch more so lots of choice out there now you may have been seeing some fuss about it lately and that's because it's about to become a first order feature in python 311 now it's already used a fair amount in the python community it's very common particularly with package configuration purposes so if you've ever seen a pi project.tamil file that's in you know tommle format kind of makes sense right so for those who've used a ini file in windows this format is fairly similar it has sections and name value pairs the sections are denoted by square brackets so if i was going to define a section for user info i might have like an account section in a file so that would be the word account surrounded by square brackets and then underneath that you get name value pairs that are variable definitions so i might have username equals bob and password equals you shouldn't store passwords in a config file exclamation mark right right exactly every name value pair is inside of a section and essentially the section is continues until you see another section definition tamil is type aware so those examples that i gave would be strings and would be surrounded in quotes all the keys in the name value pairs have to be words it can get tricky you can do things with numbers but it still treats them like words so you're better off just sticking with the way you define variables in python and that's easier otherwise it just gets confusing it doesn't have any schema mechanism there are some proposals out there for doing validation but right now unless you use a third-party library you essentially have to validate them yourself so the one of the third-party libraries out there that is common for doing this kind of schema stuff is called tableau so you can check that out if you're looking for that stuff i mentioned that tamil is type aware the types are pretty much what you'd expect plus a couple extras so strings integers floats booleans and several different variations on dates and times and time zone aware or naive that kind of thing and then arrays and what they call tables i'll come back to the tables in a second that one's a little interesting that's connected to the sections but let me start with strings very similar to python supports unicode typical escape sequence mechanism triple quotes for multi-line you're supposed to use the double quote indicator for quotes rather than the single quote so depending on you know if you're used to python programming in black that's nothing if you're me who still insists on using the single because i like it don't have to press shift exactly yeah why would i need to hit that extra key on the keyboard it's all the html is why it's because i write so much html it's all double quotes in html so i tend to default to the single so that i can wrap them in doubles but that's a tangent so anyways like python the integers support the underscore format this is one of those features i always forget is there until i see it which is you can use an underscores a thousand separator to make larger numbers easier to read and it supports that as well okay so i mentioned tables let's talk about that for a minute so this is another way of defining sections using the square brackets you can also do it other ways as well so there's two other ways of creating groups of data you can use dot notation when you're defining the key so you can say person.firstname and person.lastname for example and that'll create a section called person automatically and that's no different than sort of doing the square brackets which means it makes it easy to nest your groupings because you can have a square bracket section and then have a dot noted section inside of that so that you can sort of have groups of groups of things tamil ignores indentation sort of the opposite of python and the reasoning behind this is it actually makes it easier for you to use indentation to provide hints to somebody who's reading the file so if i've got say a section and then i've got an a subsection inside of it another square brackets i can indent that whole other subsection and to make it clear that it is a subsection but i don't have to actually see the relationship and everything yeah basically it does it and i can do that square thing by uh square bracket subsection by doing dot notation inside of the square brackets so let's say we had user in square brackets then i can have user dot player one inside of square brackets as a nested section inside of it so it's tables all the way down instead of turtles and then the third way of creating tables is there's this dict-like structure using brace brackets this is a little different from python as they use equals value name equals value rather than colon but the concept's the same it's very restrictive though it has to fit on a single line so you're pretty much encouraged to just use sections the other way that i described it instead so if you've got like a quick one-liner to group things together you can do it but otherwise just do the square brackets or the dot notation great so you've got a tomml file now what well python 311 you just use the built-in library to read it or there are other libraries that you can pip install if you aren't on 311 yet uh when you load a tamil file it's kind of like you know json.loads and what you get back is a dictionary representing the file sections are treated as nested dicks and everything else just becomes key value pairs inside of the dictionary so you just you can end up you know with your nested sections you just end up with dictionary keys pointing to dictionaries pointing to dictionaries as much as you want to go kind of thing the article goes on to talk about how to write tamil files give some advice on when to use them when not to some style recommendations and my personal favorite feature which is kind of is a little esoteric but if you've run into this problem before it's like oh neat so you can update a document losslessly so what that means is if you've got an existing file and you want to change a key value in it it won't mess with your formatting so if you normally if you dc realize if you serialize something then deserialize it and then serialize it again you lose like the comments because they're not kept in the serialization you like you're taking dictionary and put it back well you can it's it's aware of the existing file so if you've got some of that indentation that you want it'll keep it which i thought was kind of a neat little feature cool so this format is becoming more common in the python world which means the article's kind of a must-read thing you're going to run into this at some point probably going to do something with tommel in the future so probably a good read to get make yourself familiar with it so i know about the the project usage of it the other potential usages are like data and things like that or where do we see us using it yeah well so you that and the article talks about this a little bit there's there's this fine line between what is configuration like data and what is just sort of data data yeah yeah for the most part a lot of the kinds of things you would use to store use json to store you can use tamil or you know or yaml one of those kind of replacements but its intent isn't really like it's not meant as a database right like it's not meant as a lightweight database and and just like people abuse json people abuse tomol and but the original intent of it was more of the sort of configuration side of things so a nice standardized way to do that if we can all agree on it and and it also has these nice formatting things that's the intent yeah and in fact it's one of the things garen actually talks about so although it's heavily influenced by the ini format or any format i'm not sure which way you're supposed to say that evidently the uh any format was never standardized so there's variations on it out there so although it worked in windows and it's kind of disappeared since windows introduced the registry you don't see it as much anymore but it used to be really really common but everybody kind of had their own little variations on you know how did the strings work or how did the numbers work or whatever so this is sort of a formalization of that so that you yeah which which means you know everybody can parse the files between languages and not have to worry about variation well that's good yeah okay it's definitely like you said it's it's coming it's a python 311 thing you know so you need to kind of pay attention so that that's something i'm going to mention in in the article that i'm going to talk about yeah well and it's deep deeply nested inside of the whole config setup project management so like you're increasingly seeing you know it's in black and all those other kinds of things so like as the as the whole packaging system evolves in python um i i think you're going to see a lot more of it good yeah man i think that's great like there's so many ways to do everything and the idea of standards bodies like saying yes let's standardize this stuff and agree on it i think it's good and so i definitely want to re-read through the article learn a little more so my first one is by martin hines it's a medium blog it's called python and plain english the title is say goodbye to these obsolete python libraries and it's kind of like the greatest hits of conversations i've had with you or other people about lots of these sort of suggestions of like hey this has been around for a little while now maybe you should stop using this old thing and kind of move toward using sort of quote unquote modern python even go beyond the idea of python 3 like stuff from python 3 4 that's been around quite a while now now 311 is coming out in a couple months so the first one of his suggestions to sort of say goodbye is to say goodbye to using os dot path the os module has lots of other little things in it and that was one of the main things that a lot of people were using to sort of set up paths to files and in python 3 4 path lib came out along and path lib is just i don't know anybody who doesn't say that it is a good way to move forward in accessing power so much better yeah it's object oriented um it's readable it's natural to write you can do all this really kind of cool stuff with like slashes in between so forth it deals with the whole conversion so windows and back and forth that was caused all kinds of errors for certain scripts running on them i ran into that myself back when i was starting dealing with going back and forth between running scripts on two different platforms so he talks about quite a bit and has some nice examples of it i like his use of these sort of code examples it's kind of a cool like hosted by github thing those little blocks you might have seen in other medium articles and so forth and in it he imports both and then kind of shows the differences in the code styles and so forth but then he also provides these resources and they're from trey hunter who i haven't had on the show yet but i would like to have him on he is another kind of luminary in the python space talks a lot about this sort of stuff and it's funny because the links are from like 2018 december why you should be using path lib and uh he had a follow-up because he had so many comments from the first one no really path lib is great it's the name of the next article and that one's from january of 2019. so yeah there's a lot of people out there saying it and i agree it's definitely i can see why you put it at the top well some of this stuff is always just that backward compatibility problem right so yeah for example django moved to using path lib when they dropped 27 support okay that's two right yeah so i think when they went into three something i can't remember exactly where they they started dropping the the two support and now you know so they got up to a point where their minimum supported version was far enough along that it included pathlib and then oh okay so we can get rid of all this os dot path stuff right so a lot of these kinds of things that just you know for maintain for maintainers of large projects i'm not going to use both i'm going to use the one that's easiest right so otherwise you've got six everywhere so it you know it's a slow progression the schedule if you will of deprecation is always an interesting one and and i i would guess that would be a big part of sort of project planning where a lot of people may want to just rip up code and toss it away but yeah i guess that makes a lot of sense i i have comments in some of my own libraries that are okay when you drop this change this right like there's this little block that says you know the to-do block that says okay make this better reading code when yeah when you're no longer supporting whatever take advantage of this yeah yeah okay cool so there's path lib the next one is uh about using secrets it's kind of funny that's one that i have recently seen that i'm guessing in the tutorial world that i feel like i live in i always see random being used for so many different things and that's fine for like oh making a little game or doing other things but when you're generating passwords uh it's not great it doesn't produce cryptographically safe tokens and there is a thing called os dot u random and that's the one he's saying maybe you should stop using that because there's this great new thing that came along in python36 called secrets and that module really can kind of help with a lot of that stuff and i won't go into all the super details but again if you're doing something like trying to create you know passwords or do other kind of randomizing of those things um you may want to move beyond just using the random module the next one is something that you've covered in a lot of detail in one of your courses which is zone info in fact i went to look through the episode list and you also had covered it pretty heavily in the episode 30 which was with you and garrarna actually about uh python39 the release yep both you guys are on and we're talking about proper time zone support being added the big trick and i don't know if this has changed at all in two years but it does rely on you having an operating system that has proper time zone support has leveraged a lot of that but it has helped in this case you're moving beyond using pi tz and using the zone info instead it's a nice big change and and helps quite a bit by using the i a n a time zone database okay the next one kind of interesting python 37 came along with data classes and his suggestion is you probably can use data classes in most cases instead of named tuples his reasoning is that they can be mutable they provide these nice default things these built-in special methods of wrapper and equal eq and init and so forth and then it also allows you to specify default values i think they look way prettier generally data classes over named tuples but and there's a handful of other things and then i had a recent conversation with uh bruce echol and we talked about the frozen flag that if you do want to make them immutable and everything becoming a little more functional no side effects and so forth this was one of the tools he talked about in episode 116 but yeah data classes are a definite enhancement i don't know if they completely replaced what people are using named tuples for and then it gets into hey stop using print and use logging instead and okay it does require a little bit of extra setup if you're just doing some really simple stuff and you want to just use print statements along i think that's fine logging requires a little bit of additional setup in it but yes it provides a lot more useful information and especially if you're debugging that way and there actually has been a lot of conversations about debugging lately that i've been involved in and some courses coming out so definitely kind of fits in there he provides some nice resources for learning a little more about using logging and debugging in there and then that kind of relates to the next one which is f strings and i'm a huge proponent on it did a course a real python about f strings introduced in python 3 6. they're fast they look clean i find them superior in almost every single way the one or two things are uh you can't use them in logging hey so and the other one you can there's just a cost to it it's yeah kind of a little bit problematic in some ways and then there's also this idea of templates that runtime which again that's a really specific usage but in most cases they're faster and cleaner and i when i initially started talking about them because i was excited about them i was doing a course on them i ran into some pushback from from like some people i was talking to at like a user group and they were like why and i'm like well this this this this and there so it took a while and and they definitely came back and said okay i get it now so i don't run into that kind of pushback anymore so i i found like we're on our what third fourth different kind of string formatting mechanism inside of python sure right and because i came from the sea world sea world not just about whales with you know percent ass percent f and all the rest of that uh it was an easy thing to sort of adjust to when i got to python and then the you know dot format i was like whatever it doesn't really get anything like it just doesn't make any difference for me and it didn't feel easier and and so i sort of went through and i kind of never adopted and then f strings came out i was like oh no this is better okay yeah right so so i skipped the ones in between it was i'm always either you know what the format that logging still uses the old c style yeah or f strings that nothing in between yeah and then the last one is actually uh about tommel there was a previous library called tom lee t-o-m-l-i there's a new one called tommel lib that is sort of replacing it so yeah it's a nice list i think martin did a good job here kind of going through it and talking about it but i thought it was just kind of fun as a wrap up of all these things that i i've had lots of these other kind of conversations about and definitely things to keep in mind maybe things to add to your deprecation list also [Music] this week i want to shine a spotlight on another real python video course you've probably experienced syntax errors or other runtime errors in your programs but logic errors in your programs cause unexpected behaviors called bugs removing these bugs is called debugging the video course is titled python basics finding and fixing code bugs it's based on a chapter of the python basics book by david damas and in the course instructor martin royce takes you through learning how to debug inside of python's built-in code tool idle the interactive development and learning environment and how to capitalize on its built-in debug control window you'll practice debugging on a buggy function setting breakpoints and inspecting values walking through a four-step process for identifying and removing bugs and learning alternative methods for debugging your code debugging is a skill all developers need to work through moving beyond print statements in your code and learning how to implement a debugger is a worthy investment in your future and like all the video courses on real python the course is broken into easily consumable sections plus you get additional resources and code examples for the techniques shown all of our course lessons have a transcript including closed captions check out the video course you can find a link in the show notes or you can find it using the enhanced search tool on realpython.com [Music] yours is kind of related but a little different what's your next one yeah it's sort of the same vein this is by eugene yan and it's called uncommon uses of python in commonly used libraries and i kind of like the premise here he's been reading other people's python libraries in order to learn to be more pythonic and the article describes some of the habits that he's trying to emulate uh so this is a little deeper than your typical you know baby's first python this is what a print statement looks like yeah yeah there's some darker corners here the the first one he talks about is the use of super in base classes so if you've done any object oriented programming in python you'll have come across super it gets used to access the parent class and the most common place you'll find it is inside of the dunder init method to make sure that the class you're inheriting from setup gets called as well and the recommendation here which seems a little weird is you should do this even in your own base classes so you might think well it's my base class i know it's the root why bother well it turns out that this has an impact on how mix-ins work so let's say you've got a class called person that inherits from another class called address and phone sorry from a class called address and a class called phone so i've got person based on address and phone in order to get all the data attributes together in the same place if address doesn't call super in under init phones dunder init won't get called okay and this has to do with how what's called method method resolution order works on python inheritance and how you chain together the mix-ins so if you forget to do this in your class even if you think it's a base class you will be interrupting the chain of inheritance that happens as the other mix-ins get pulled and as you can imagine that is a tricky tricky bug to find because it's like well my constructor is not getting called why not that is a weird thing so general recommendation here is you should just call super all the time inside of your base object and you remember that all objects actually inherit from a base object class so that super is actually doing something it's calling the base objects dunder in it so this is why it works this way but it is one of those that's a little bit like i said a bit tricky to find if uh if you're not aware of it so that's a good recommendation can i stop you for one second yeah there's a this term that's in my head about object-oriented programming and kind of the thought process the idea of you using mixins generally what is that called like when you're as opposed to like you know just inheriting from a base class and kind of adding on it it's there's like these different terms for it i can't think of it it's so you you mean like multiple inheritance is that what you're well the idea of multiple inheritance the idea that you're kind of adding attributes from these other classes as opposed to like it's different from like parent and child and kind of yeah a mix-in is generally considered so so pure and you're getting into a bit of an academic realization of it right so yeah yeah so a typical inheritance is is sort of the is a kind of mechanism right and yeah versus the haza whereas the the mix-in is often a way of pulling in the hazard is really what it comes down to right so an example that i have in one of my libraries is oftentimes inside of django i have two fields in almost every one of my objects which is a create timestamp and an update timestamp so that if i'm trying to debug when something has happened to an object i can go in and look at the database and i can see oh this was created on this date and it was updated on this date so i want this everywhere yeah so i have a timestamp mix in so if you're creating person class you're not really making them a time-based object so you're not inheriting it from that perspective you're just mixing in these fields yeah but it's it's a bit of a sort of an academic distinction really is what it comes down to yeah but but i see that kind of methodology of adding these additional you know hazard functionality kind of things that this is where you're going to run into it because you're going to be have multiple inheritance like you said that's right and i generally find mix-ins easier to mentally props process than sort of the parent-child concept because like i said like you're just adding some fields you're just integrating the concept whereas that parent child concept is more of a okay i've got a person and a person is an animal or a square is a rectangle and oftentimes the mix-ins are either providing just attributes or helper functions yeah and they don't really need to have any understanding of the parent so they're kind of a separate way of it's a lego block kind of uh mentality yeah i got really into this with plotting libraries and mixins were really handy for like okay you want to add legends and you want to add this thing and you wanted this kind of functionality and i was like yeah oh this really makes sense to me to inherit quote unquote these extra things and yeah yeah cool thanks sorry for the digression no it's noise yeah so uh the and i'm mentally going through the people who are going to be screaming about this christopher use the phrase constructor there are no constructors in python then he called it inheritance when it was a mix oh boy so yeah so i'm using a lot of the language there very very loosely to to talk the point so you can scream in the comments but gives you something to do on the internet [Laughter] so the second chunk in the uh in the article is again this is back into sort of that class modeling object-oriented philosophy stuff and he's got some recommendations that he came up with for himself on when to use instances class methods and static methods inside of objects so instance methods those are the ones we are your normal object methods they have a reference to the object passed in and that's self now that's by convention you can name it anything but don't itself so anytime you're inside of a method inside of that object you're getting a reference to the parent class the parent object excuse me so class methods are distinct from this they're marked by a decorator that says that class method and they don't get self but they do get a reference to the class so this again by convention this is usually spelled cls it doesn't have to be but everybody does it that way so don't go being unique and class methods are for the case where you don't want an instance of the object but you do need class information so the typical use of this is things like a factory constructor so if i want a method that so one of the places where i use this is let's say there are two or three objects that have to be constructed together then i might have a class method that constructs them binds them together hands them references to each other whatever they need to and then you know hands out the parent object kind of thing and then by contrast static methods don't have access to self or the class so they're subtly different from the class method they don't need the instance object but they also don't need the class info and it really is a signal that you're grouping together a family of functions as methods i don't see these get used as much in python because the concept of a module can often solve the same problem so it's sometimes it's a bit of a sign of you're a former java programmer because they were they're very common inside of java yeah i felt like they were added for that purpose yeah i it's so like i'm not a hundred percent sure of this but i think in it's been a long time but i think for example the java in java the math class has a whole bunch of static methods for like cosine sine whatever and python's answer to all that is those are just functions inside of a module right so this is kind of that difference but so so the concept here was just sort of trying to make sure that you know when to use what and and how to do that so the article talks about that in addition to talking about reading code he also talks about reading docs and that's a sign of an uncommon programmer because nobody reads the dots so he talks about the fact that having some design principles outlined in the technical documentation can help you understand the coding structure he gives an example of scikit-learn where they talk about two design principles one is a consistent object interface and the second is composability so the kind of information helps you understand why you know a lot of the transforms in scikit-learn all have very similar methods right because they're following this philosophy and if you've got that stated somewhere a particular you know a diagram that goes with it it helps someone who's new to the library wrap their heads around how these things work and what you would expect to come out of the objects so that example you were using before of you know mix-ins with the graphs and things like that well if you're you know if all the graphical objects have a ability to have an overlay which has a little box inside of it and one of those overlays is a legend then you know that composability helps this so a diagram that talks about that can be useful yeah yeah so the article touches on a bunch of other stuff as well and just highlighted a few of the key ones it talks about some uh use of conf test when to use dunder init the file rather than the uh um constructor i just said it again [Laughter] and uh and the the use of absolute versus relative imports which i do not see eye to eye on him with but uh you know it's always good to see somebody else's take on it so all in all some interesting thoughts on some deeper python coding principles and yeah and i kind of love the fact that this comes from a place of him digging into code that he respects rather than it just being like some random blogger saying you should do it this way he's actually you know pulling this out of common big python libraries and go well hey scikit-learn does it this way and this is why and that's uh there's some there's there's value in that yeah no i think that's good kind of back up your your reasoning for your opinion yeah as opposed to just being an opinion sitting there yeah exactly yeah and that last little section that you're talking about i think is going to lead into our our discussion this week too a little bit what should be documented and and where and how yeah so that's cool yes all right well my next one is ian curry one of the real python team members he wrote a really kind of amazing article about hey how do you get your python coding environment set up on windows sort of a setup guide with lots of suggestions lots of packages and tools and just kind of like you know in his opinion in a lot of ways like best practices to kind of get you moving forward and i learned a lot um i have often on been a windows user throughout my life mostly for business reasons and job reasons and so forth some cases i was able to install things that i wanted i currently have a pc it is mostly a sort of a large steam machine if you will running uh video games and things like that when i wanted to so i decided to go ahead and go through this article and try to set up windows on it and i won't go through every single detail because there are a lot but there are some keynotes of things that we've touched on before across the show and i wanted to kind of touch on that a little bit and some kind of cool surprises i think it's a good resource definitely if i know that probably the majority of people that use python are on windows which is always kind of like a interesting thing to think about and that could be again business reasons or others and so forth so his article starts with hey make sure you're updated which is uh always kind of a little bit of a long process if you haven't done it in a while so he talks about that and you know getting things updated he is focusing on windows 10 though there's a note that most of the steps will equally work on windows 11. i have not i decided not to do that upgrade yesterday and do windows 11 i went ahead and kept it on windows 10 but i did get it up to date and made sure everything was all looking nice and clean and ready to go and so one of the first things that he had you do was there's a new windows terminal which is great because before it was just sort of this uh shell command prompt thing that people were using and a little clunky and this one has been written specifically for windows and there's a lot of really great development happening at microsoft right now that is you know four developer-centric tools that are not just within like say net and other things like that and so the new terminal is nice i i thought it was a lot nicer than what i was using before in there you can get it directly from the windows store so that's a super easy download as far as configuring your system he talks a little bit about that showing hidden files which is a common thing that a developer is going to need to do and by default that stuff not only are you hiding files but you're also usually hiding extensions by default and things like that and then kind of going a little further managing software in windows he talks a lot about loosening your execution policy by default there's a lot of things you can't do without being an administrator and there's actually a fairly quick way to do that on here where you can kind of right click on say the terminal and then you have an sort of an administration session running and you can say you know run this as a system administrator and you can that'll be sort of temporary and that led to installing this package manager tool which those of us who have been on the mac platform and been developed for a while you probably have heard of something called brew or homebrew which is a very popular tool for installing tools and other things that you can kind of use across your system there hasn't been something like that on windows for well when i was getting into it and so the new one i'm not sure if it's age but it's a thing called chocolaty so is a package manager you can think of it like again on mac homebrew uh if you are a linux user you might have heard of apt apt there's a couple others that are mentioned there i guess microsoft is working on its own win get uh is their thing it's not i guess quite there yet but i've heard this one mentioned before and actually was pretty easy to set up and was in my opinion easier than my experiences with homebrew which have always been kind of clunky i don't know why but it just always has been clunky for me and very hands-off and hard to kind of get through and this went really smooth and i was kind of impressed with that i immediately followed some of the other advice on there and tried out installing a couple other things which i installed this uh zip tool 7-zip just to check out how things were working that worked fine it includes you know upgrading and uninstalling packages and doing that stuff and then he suggests this tool which i thought was actually kind of nice in anybody who's bought a pc if it was from a big name brand it might have been subsidized by having a bunch of crap wear on your machine and he suggests a tool that gets rid of it it's called the bulk crap uninstaller or bcu and i guess i had done a pretty good job i have a tremendous name of the brand of the computer but it was configured pretty well but it had like i don't know different virus stuff mcafee and so forth and i had gone out of my way to like manually uninstall that and it was a little bit of work anybody's had to do that yourself manually knows and this thing is actually this the bcu is a nice tool for that it actually shows everything if you've gone into the uninstaller in windows and tried to do it yourself it's a lot of work very often and usually waiting for one single thing to be uninstalled this allows you in its name to check mark a whole bunch of things and say okay just remove all of those and it tells you if there's uh you know the certificate on the thing if it's a registered application if it's from the windows store app so forth is there an uninstaller for it kind of nice little tool so that was a neat find and there's a nice comment at the end of the article saying this guy was like hey i freed up like several gigabytes thanks just with that one little thing alone which i think is going to be a common thing so the installation of the windows terminal you probably then also get powershell if you didn't already have it there isn't a simple way to get right to the latest one which is called powershell core which is an upgraded version you have to kind of go through a couple extra steps to do that so he takes you through that and powershell i think is that version 7 and it adds a lot more i want to say unixy kind of stuff to what you were doing before there which is nice so a lot of the common commands that you you would be used to on linux come across so you get ls and cd and rm and all the things that you're used to there one of the problems a lot of people deal with on windows is working through environment variables a whole great section on that and getting that ready to go then finally getting to setting up your core python stuff getting python set up on it he suggests right away to jump to pi m there is a pi m for windows project which is a port i think pyeon is a great tool depending on what you're trying to do i am kind of more of a vanilla python kind of person and so i went to the windows store and downloaded python and that actually worked pretty well which kind of keeps things a little simpler but pyam adds the ability to have multiple versions installed and to switch between them and set up virtual environments between them and kind of do some interesting stuff if you're testing across lots of environments and and so forth um i think that might be a handy tool for that again this was not going to be my primary machine so i didn't want to go through a bunch of extra stuff talks about setting up git setting up ssh for your git account and then vs code and then some other additional stuff so just a great article lots of detail get involved in working in windows for your python environment and so hats off ian good job yeah but there's that little to me the most important part buried there in the in the section at the bottom other nifty windows software which is the subsystem for linux yeah yeah so that's my usual recommendation that you know if you're solely in a windows world and never touch anything else you know it's your home computer or whatever then yeah you may not want to deal with it but if you are ever going to be writing anything on a server anywhere it's almost always some sort of posix based whatever and once you've got that sub system in you're inside of you're essentially running linux inside a little box so as a consultant one of the things that sometimes happens is your clients have expectations as to what you run so and in the days of remote they essentially like you sign up you sign a little form and then they fedex you a laptop and then go here's your laptop and it's all completely locked down yeah yeah and so occasionally i'm in that space where i have to do that with windows and my one ask is always okay can i have the sub system on it and then and and back to your comment about things like the admin because oftentimes your clients won't give you that um but if they if they will allow you to have the sub system on it then as long as you're inside of that box you can control your libraries and install it and everything because you're you're running inside of that little uh inside of that little environment so it's my my go-to answer i need to play through that because i the article doesn't really get into it just kind of offers like some suggestions is that other things you can do but that has been a common refrain i keep hearing i'm sorry i should probably go through those steps and set up on my other machine again it's more of my gaming machine yeah well at risk of sounding like an old man i used to use cygwin for a lot of that kind of stuff and it was the same thing i want a little unix style shell running inside of windows and now that the linux subsystem's there you don't have to deal with it and the beauty of it is actually that all the file paths are accessible so you can run your windows software like bs code you don't have to run like an x server and you just point vs code at the place where you keep your python files and then you can you know run things in the command line or run your django or whatever nice the same way you would in a unix so yeah well that kind of gets us into this discussion which we'll kind of keep short because we're running a little long got a lot of details we're getting into this week but the discussion was an article about technical writing for developers this is by eluda it's on a website called css tricks um i guess it's maybe a digitalocean site but i like the article in the sense that it covered a lot of the overarching things of like okay what is technical writing and is commenting in your code technical writing how much should be included in that and that kind of cross section if you will or even that sort of uh set theory kind of thing where they have the two circles of technical writing versus coding and where do they cross over and it kind of goes a little far into like you know what you know actual grammar and things like that but i want to ask you did you when you were in college and you know i have an experience of college from the late 80s and then i had another experience in the early 2000s and in the late 80s i don't remember a technical writing course and i'm wondering if you had any of that any school stuff on technical writing i don't remember i don't even think there were options on it okay i i came up through engineering they they essentially they they ran a test in the first entry in september and went oh you speak english goodly great you don't have to do this ever again so yeah that not to say that there may not have been courses there but it wasn't part of my experience yeah i ended up going and kind of pursuing my degree because i had you know i didn't finish college early did that whole rock band thing went off and toured the us for a few years there and i went back and said oh let me take some technical courses and and so forth and technical writing was on there it was interesting course i learned a little bit but it was interesting to kind of look at like structurally how this has been added on to a lot of the curricula today of like talking about like how this is done and and so forth and i just find it's an important skill it's different than you know regular writing there's sort of a precision to it the way that you're communicating everyth
Original Description
Have you attempted to set up a Python development environment on Windows before? Would it be helpful to have an easy-to-follow guide to get you started? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder's Weekly articles and projects.
👉 Links from the show: https://realpython.com/podcasts/rpp/122/
We talk about a Real Python tutorial for configuring a Windows coding environment. The guide contains valuable suggestions, best practices, and powerful coding tools. It also covers how to use a package manager, a new windows terminal, PowerShell Core, and a program to manage multiple versions of Python.
Christopher covers another Real Python article about using TOML in Python. TOML is a configuration format for building and distributing your own packages. We discuss how TOML parsing will be added to Python's standard library in version 3.11.
We cover several other articles and projects from the Python community, including technical writing for developers, a news round-up, saying goodbye to obsolete Python libraries, uncommon uses of Python in commonly used libraries, a prettier `ls`, and a project for advanced hot reloading Python.
Topics:
- 00:00:00 -- Introduction
- 00:02:13 -- Python 3.10.6 Released
- 00:02:41 -- Python 3.11.0rc1 Released
- 00:03:13 -- Django 4.1 Released
- 00:04:07 -- 10 malicious Python packages exposed in latest repository attack
- 00:05:12 -- Protestware: Why Developers Sabotage Their Own Code
- 00:06:41 -- Python and TOML: New Best Friends
- 00:16:19 -- Say Goodbye to These Obsolete Python Libraries
- 00:25:51 -- Video Course Spotlight
- 00:27:26 -- Uncommon Uses of Python in Commonly Used Libraries
- 00:37:56 -- Your Python Coding Environment on Windows: Setup Guide
- 00:48:20 -- Technical Writing for Developers
- 00:55:24 -- reloadium: Advanced Hot Reloading for Python
- 00:58:07 -- pls: A Prettier 'ls'
- 01:00:56 -- Thanks and goodbye
👉 Links from the show: https://realpython.com/podcasts/rpp/122/
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
📰
📰
📰
📰
2026 Is the Year Everyone Is Redesigning Themselves. Are You?
Medium · AI
EU tech chief and Tim Cook hold ‘constructive’ talks as Siri AI stays blocked in Europe
The Next Web AI
Sonnet 5 launches: Opus performance at lower cost
Dev.to · The Dev Signal
Claude Sonnet 5 Didn’t Just Get Smarter. It Changed the Economics of AI.
Medium · AI
🎓
Tutor Explanation
DeepCamp AI