For example, in my live streams, i’ve got a little script to actually open up a playlist and start playing that music on the stream. I could do that in something else, but why bother but i’m also not up for the task of bashing my head against the wall, because i want everything to be done in posix, shell script sometimes it’s easier, just to use an actual scripting language like, for example, Python and today i wanted to do a video talking about why python is my favorite programming language and i know that’s not going to be a popular opinion. I don’t really care. I like python. One of the things that i use python for is getting quick and dirty scripts done sure it’s not going to be the fastest implementation out there, maybe rewriting it in something like c or rust, or any other language would be better at like if i actually care About the performance, but if i just want to do something like pass, some json handle some emails. Do some network requests do some image handling? All of that stuff is just in the standard libraries i don’t need to go and find a library for it. I don’t need to go write my own implementation, for it just is already there and because it’s already there, it makes taking that script to a new system. Incredibly easy, as long as there is a python installed that is new enough to actually support those features.

It’S just going to work now, obviously, not everything is in the standard. Libraries. If it was the standard, libraries would be terabytes and terabytes large, but there’s everything you need there to get most general tasks done and because all this stuff is in the standard libraries, as you would expect, it is all really well documented if you’ve never looked at The python documentation before python sort of shows you how documentation should actually be done. So if we go to all versions here, every single version of python has its own separate documentation, including all of the changes that were specific to that individual version. So let’s just go to the latest version. So 3.9.5, as a recording and let’s say, i want to look at the documentation for element tree element tree is the module for parsing xml, so let’s go into that one and every possible part of this is documented, includes things like examples as well examples of one Of the things that a lot of pieces of documentation are severely missing, but this actually shows you how to use it. Not just you know what the api looks like. Obviously it has that as well, but having the examples there are incredibly useful and then leaving the standard libraries you realize, because python is such a popular language and it’s got this whole idea of making stuff easy and making it self documenting. I don’t like the idea of self documenting, but in this case it sort of makes sense because of this whole mentality, you realize that everything you could possibly want to do with python probably has a third party library.

Now i know the hardcore c guys who want you to write everything yourself, make it as quick as possible. Probably will think this is a bad thing, but when it comes to a language like python, this has a very different use case. Where python is here to get things done in a quick and dirty fashion, and if i can just glue a bunch of libraries together and get what i want done in five minutes rather than five days, i think in this case it’s an absolutely amazing thing. I do think some developers take this too far and use python for things that it shouldn’t be used for, for example, a file manager and when they do that the performance severely suffers, but for the simpler tasks. This just makes it easy, even though the python documentation is amazing, and even in the case of third party libraries, it’s generally good, not always the case. Sometimes it is a bit of a mess, but generally it’s at least workable, even though that is the case sometimes having a bit of extra support can actually be helpful in places like stack overflow, reddit wherever it is, that you get your programming information from and python Is one of the biggest languages in the world? That is something you cannot deny and because this is the case pretty much any question you could want answered probably has been answered already. Obviously, don’t just take the answer at face value, but it does give you a baseline to work from to build on your own solution, even if you’ve never written a line of python in your entire life and try to avoid python applications like the plague.

You probably already have the python interpreter actually installed, because a lot of applications just have a script somewhere in the background that actually need it. There’S, no way that you could run a modern linux system and avoid python. If you managed to do so. I would be very very impressed this just removes any barrier to entry to actually start working on python code and likewise python runs on basically everything. Obviously you have like the normal things like windows, linux, mac os x. But do you want to go and run it on something like os ‘0, something you may have never even heard of and probably have never even touched, or maybe solaris or risk os or ios, and there are probably other packages that aren’t actually listed here and while This isn’t a big deal once you actually know the language python has an incredibly simple syntax, where, even if you don’t really know what’s actually supposed to be going on in that program, you can generally just read it and get a fairly simple gist of what’s. Going on python is very similar to the english language, for example, the way it handles loops. I didn’t like this when i first did python, but for variable, in whatever thing: you’re iterating over that’s, just a simple structure to understand, and it makes it so if you just don’t touch your scripts for a couple of months, you can generally get back to speed On them, without much hassle, obviously python, if you go into some of the more advanced stuff, does have some sort of funky syntax stuff like if you get into like slicing and f strings.

It can look a little bit weird, but besides that stuff it’s fairly easy to understand – and something really important to me – is having good tooling around the language in the case of python it’s, very, very easy to set up a dev environment and get syntax checking and Things like that, just working in a couple of minutes, some languages out there are a bit more of a hassle, but in some editors, python is just working perfectly fine out of the box. Now, when i use python, i generally set myself a couple of rules to make sure i’m heading in the direction that i think is important. So one of those rules is if my script is going to be a bunch of os dot system calls. I should just be using shell scripts, so os dot system basically lets you call external applications, so i could do something like os dot system and cool ls os dot system called grep things like that, because if you’re using python like that you’re effectively, not using python, Now i do have an idea where i will need to call os.system at least once but that’s going to be to actually show the results, basically i’m, going to use it to open up d menu. Another thing is: if it’s going to be a short script like under maybe 20 lines of shell script, i might as well just go and write it in shell script. I generally keep python for any of those more complex tasks, that’s going to actually take a much more to actually write and because i’m writing python for myself not contributing to anyone else’s project.

I generally don’t care about the pythonic approach, so that, basically, is the community to find way of how you should actually write python, even though there are like three different ways to go and format a string, only one or two of them are actually accepted. Now. Obviously, if i was committing to someone else’s project, i would be following whatever style guide they’re using, but i don’t think it’s that important when you’re the only one who’s actually going to see it. Maybe someone will download your repo and have no idea what’s going on, but they did just download your personal scripts, so they sort of have to expect that some of them might be a mess. Now an example of something i’ve used python for recently is the sound board that i’ve been working on where, basically, i want to be able to press a key on my keyboard and it will just play a sound now. Some of that isn’t really that difficult so doing the audio output. I could do perfectly fine with something like ff play, but when it comes to the keyboard input, this would be a little bit more annoying to do with shell script. Sure i could take something like xev and then strip out the key presses and then run ff play whenever a certain key press is made. But then i have to come up with some ways to do event handling to make the script so it’s not constantly wasting cpu cycles, and while it could absolutely be done in shell script, it would turn into a massive headache very very quickly.

So it just makes more sense to just use a language that actually has event handling built into it already and just go from there. Obviously, we all know that python is slow, but sometimes it makes sense to prioritize development time over time savings while actually running the application. Let’S say that i write a script in python and it’s five milliseconds slower than writing in some other language, but it takes me let’s, say five hours less time to actually ride it sure, eventually that five seconds of time loss will actually add up to more than The five hours, but how many runs is that actually going to take, maybe for something that’s run a thousand times a day that actually is going to make sense, but if you’re running it maybe like five or six times a day, is it really that big of A deal to waste a couple of milliseconds while running the application. In my case i think that’s perfectly fine, but maybe for whatever you need to do. That’S not going to be the case in which case feel free to go and use something else. That’Ll be everything for me and before i go, i would like to thank my supporters. So a special thank you to joachim donald logan, michael andrew mitchell, nathan, david caldwell, brennan, chica, bender, jamie joseph josh, michael peter, the steven t’s through 22 shah and all of my two dollar supporters. If you’d like to go and support them links down below it’s, my patreon subscribe start leaving all that sort of stuff.

I’Ve got my podcast tech over t available, basically anywhere i’ve got a gaming channel called brodie robertson plays where i live stream twice a week and also upload youtube shorts from those live streams, and this channel is available over on odyssey.

https://www.youtube.com/watch?v=3HfvoVGvno4