r/Python • u/DecodeBuzzingMedium • Sep 15 '21
Beginner Showcase 26 Useful Python Snippets for Lazy Developers
Here are some of my most useful code snippets that will indefinitely make your life easier as a programmer! There are some Python code snippets that can be used to solve day-to-day problems and can make your laziness shine! I have explained each snippet in detail so that you don’t have any doubt. So check the link below:
3
u/OdinsOneG00dEye Sep 15 '21
I can tell you now with a number of years experience that 'lazy' students can be the most effective programmers. To the point where sometimes you have to grill them to check it's their code!
Lazy does not equal poor always - it can be efficiency at play
6
Sep 16 '21
Wish my stats professor understood this, he wasn’t too enthusiastic when I automated my homework 😂😂
5
u/circamidnight Sep 15 '21
I like using decorators in Python but I don't like writing them. I have this little snippet that get's copied to almost every project I start.
https://gist.github.com/scrussell24/025eadc8faf35d841f4aa41ee0265acb
7
u/Einfach0nur0Baum Sep 15 '21
To be an lazy dev is like to be a blind car driver on streets
5
2
91
u/SomewhatSpecial Sep 15 '21
What a weird article. Most points are shallow descriptions of randomly chosen extremely basic language features, others outline implementation of extremely specific behaviors. Who is this for?
"
dict.updateexists""
dict.copyexists"An actually useful trick, but not needed since python 3.9 added the dictionary merge operator. Would've been nice to mention that here.
"
sortedexists""builtin filesystem path modules have a way to check if file exists"
"
idexists""
__getitem__syntax exists""
__getitem__syntax exists" (again)A way to access a specific file metadata value. Also, "
globexists""slicing exists"
"slicing exists" (again)
Straight up bad advice. You do not use the
randommodule for cryptography purposes, as you would know if you read the documentation"
zipexists""list comprehension exists"
"
forloops exist" (seriously?)"
dicthaskeys,valuesanditemsmethods""
str.__mul__exists""
timeitexists""slicing exists" (AGAIN)
collections.Counterbut worse"
operatorexists""
forloops exist" again? "smtplibexists"?"
setexists""
list.shuffleexists"Straight up terrible advice again. You do not need a third-party dependency for such a simple action.
Another implementation of a weirdly specific behavior
This reads like a beginner programmer decided to list 26 random things he knew how to do, presumably out of arrogance or in an attempt to gain internet clout. This information does not deserve its own article. There are a ton of better resources out there written by people who actually know what they're talking about.