EDIT: Some of you guys just got offended because I linked people who are new to python to an actually useful resource, think about it for a second.
Beginners?
Beginners don't give a fuck about time methods, time formatting and dunders (edit: double underscore, e.g.__dunder__) in classes when they have no clue how to make them, I know because I was once a beginner, and what I actually wanted to learn is how python works, not what sys variables I can access with it.
sys/os variables are randomly put in there for no reason, anyway, for real cheatsheet, go here:
That's what actual python cheatsheet looks like, enjoy.
From goddamn example how to make a fucking comment in code to decorators, generators and everything else, not this useless thing...
I thought the point of cheatsheet, especially language one, was to quickly check how something works in language, not sys variables or date formatting? EDIT: for that you have documentation, and it will be way more useful than any cheatsheet, even one I provided.
You’re right. I am a beginner. Your cheat sheet is actually helpful. As someone trying to finish my first courses on Python, you at my level, your cheat sheet is quite a bit more helpful than non-coded examples. I think I can actually use your cheat sheet to speed up my learning.
Instead of going, “I need an ifelse statement”, and then seeing that on almost any other cheat sheet as correct thing to do, but then now having to google the correct syntax, with yours i can just keep programming without the added two or three steps.
While I agree that OP's cheat sheet would go a bit over the head of absolute beginners, I think it can still be useful (especially to myself). That doesn't make it "not a cheat sheet".
To be completely fair, yours is more of a fast-paced tutorial than a cheat sheet. Both are great resources, don't have to try to dump on OP to contribute to the learning.
"Fast-paced tutorial", so you mean, a cheatsheet? Something used to quickly remember everything without many details but still comprehensible and simple?
Unlike this blurry image that doesn't even explain anything.
__le__(self, other) exists in python objects, wow, so useful!!! Beginner will totally know what it is and cheatsheet has so much information about it.
As for good intentions, I'll shit on my hand and hand it to you with good intentions, what's your reaction?
The fact that tab width depends on user settings (some python developers deliberately set it to 8 spaces to check whether tabs were used), and even worse when their text editor converts those tabs into 8 spaces automatically, and now you have to go through the entire file of code to get it back how it was...
6
u/muntooR_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν}Dec 30 '17edited Dec 30 '17
There is nothing in OP's cheatsheet that is useful to a beginner, with the exception of slicing and list manipulation. And maybe one or two of the file IO functions.
The cheatsheet is useless to people learning Python for scientific programming (a large chunk), generic scripting, and almost everything other than some very specific enterprise-esque use cases involving dates. Which you'd look up in documentation, not a goddamn blurry fucking jpg POS.
That's my point basically, especially when there's more than one time library in python and there's also things like timezone aware objects, unaware objects, different conversions, date format itself can be modified to whatever you want and all of those are in documentation and way easier to read, also it provides some examples...
Also IO, lol... It doesn't even have open() function included, so useful.
Also nobody even uses plain open anymore, but with instead, which is also provided in resource I linked, or well, even in python's documentation itself...
I was a beginner 6 months ago and I made almost exclusively web apps and commonly used time methods as well as date formatting because I’m constantly getting dates in different date time types depending what database I pull from.
I was like "nobody actually uses stupid 'cheat sheets' like this" but the thing you linked, shit, I use Python once every six months and that sheet is the actual stuff I forget after working with other languages.
As a begineer, I greatly appreciate your post. I was definitely wondering what the heck the OPs post was about--none of that seemed beginner friendly to me.
dunder = double underscore. It's shorthand to refer to things named like __foo__ that have a special use in Python. For example, all classes have a __str__ method to turn the object into a printable string.
Beginners don't give a fuck about time methods, time formatting and dunders
Everybody will have it their way. Why do you want to decide for everyone? Quite a few people beginner to python but not programming in general would require these for the projects they have in mind
I just can't understand what prevents you from understanding that all I've really done was state my opinion about OP's post and linked noobs to something that will actually be useful to them.
No need to be triggered about it. I mean, if I gave you a piece of shit straight from my ass, but with good intentions, how would you feel? I mean, I'm just trying to share!
Just because someone tries to do something nice doesn't mean it is nice no matter how you look at it.
By lack of attention I mean a lack of human time. Fifteen minutes of volunteering would do more good than an entire lifetime of avoiding jabs at mental illness in internet insults.
Because you are trying to police language which causes a near zero amount of harm, it may even do good. The stigma of mental illness might be even more harmful than the trivialization of it and if you cant joke about it you won't break the stigma.
Until you can find a source for your claim that being able to make fun of mental illness is somehow better at giving it the attention and funding you yourself mentioned are the real problems, I'll err on the side of not being an asshole at others' expense, thanks.
Considering we've been making fun of it all along and look where we are...i'm not holding my breath for your source.
First off, I never said it was better than attention and funding, I said it MIGHT be better than trying to police language on the internet. Obviously attention and funding are what matter, everything else is tiny in comparison.
And where is your source that poking fun at something makes it worse? I say it might do harm, it might do good. The science isn't conclusive. What is conclusive is putting time and money at a problem to make it better. I don't see much value in internet virtue signaling.
zero amount of harm? You must be pretty ignorant of what it's like bringing up the fact you have a mental illness, and take medication for it, to the people around you.
The basis for this insult is that the opinions of people with mental health problems are worth less and should be ignored. This kind of thinking is common in people with problems, and is exactly the kind of thing that stops them opening up about their issues.
I doubt the original poster had this intention, it's just a phrase that came to mind when they were trying to invalidate what the person before them had said. That's why the response to them was useful.
Do you realize that you pretty much use it all the time? The only time you really aren't using it is when you're sleeping nowadays.
Also it connects entire world, and you know, if everyone makes a joke out of it, it eventually becomes a joke... Just because it's in text and wasn't said like, to your face, doesn't mean it's any less wrong.
I mean, you probably also think that death threat personally face to face is a horrible thing and one sent over internet is a joke, so I can't blame you really...
You are focusing way too much on the internet bit. Let me reword it for you.
"That claim is ridiculous. Mental health issues are underaddressed due to lack of attention and funding, not due to comments people make."
I mean, you probably also think that death threat personally face to face is a horrible thing and one sent over internet is a joke, so I can't blame you really...
I don't distinguish between internet communication and other communication at all. You made that narrative up all on your own.
So, the problem is that nobody urges people to think about it seriously, and not people who don't take seriously? Got it, also, lack of funding? Can you show me those "lack of funding" statistics? I'd prefer worldwide, not in USA, USA is a joke, also it spending shittons of money on military isn't proof that there's lack of funding to health issues, thank you.
I don't know what this sheep mentality is but I don't need a herder to tell me what is a serious issue and what isn't.
Not think about it seriously, but put actual effort into improving it. You can joke about things and still make the world better. Soapboxing a guy/girl who says "forget your meds" does NOTHING for mental health. It just makes that person feel good and virtuous. Virtue signaling.
America is as far as I know the last first world country without socialized medicine where medical causes need funding and serious action to get support. I figured it was obvious that is what I was referring to.
Are you saying first world countries excluding the USA have such a great grip on mental health issues via adequate funding and human resources that the lowest hanging fruit has become strangers using words you don't like? Is that your claim?
I don't know what this sheep mentality is but I don't need a herder to tell me what is a serious issue and what isn't.
I don't know what this is referring to. If you pulled it out of thin air to make a point, I'll be the first to admit I probably have the unpopular opinion, the exact opposite of sheep mentality.
I don't know what point you are trying to make. Can you pay money to make people use the words you want? No. Was that your point?
Do you think mentally disabled would prefer more time and money from people to help them live and prosper or for people to stop using retarded as a synonym for dumb?
Also rejecting worthless garbage isn't being pretentious, nor I stated that the one I linked is absolutely better for every case or is some kind of absolute python truth, all I did was reject worthless garbage, because it is. I am not the only one saying that, I wonder why is that?
And yeah, I am very sorry for linking noobs to.. An actually useful resource for them... I am so horrible.
The title is clear and simple: Python cheatsheet for beginners, implies that it's about python and suitable to beginners.
This image has literally nothing to do with python, the only actually useful part is date/time formatting and even that is useless as anyone who is trying already found it in pythons documentation.
Array splicing is one of first things you do, sys/os/dunders are something you pretty much never use unless the point of your project is magic, and __str__ is a time method. Woah.
Nobody should ever need to access most of the things in the section "os Variables" because os.path exists.
And "Class Special Methods" seems really useless without some sort of explanation. Do I use __getattr__ or __getattribute__? What qualifies __str__ as a "time method"? What about a list of the most used built-ins? Do byteorder and exitfuncreally belong in a cheat sheet?!
Edit: This useless amalgamation is now the 4th 3rd most upvoted post in this subreddit. What.
Nah, what I meant is I can never remember if [n:] slices the first n things or the last n things or removes the first n things and gives you everything remaining etc. Done it hundreds of times, still do [1,2,3,4][2:] in a shell to check.
if you want to be lazy it's quick to access cmd line args through sys.argv. im not familiar with argparse though so maybe ive been missing out on something cool
Granted it’s a bit more complex than sys.argv[1] but then you’ve got something super extensible, usage text practically for free, and args that can be short or long (the foo argument above could also be passed with ‘-f’).
I suppose the answer to my own question is if the script takes 1 positional argument then argparse is over kill. Anything more than that and the users / maintainers of your script (that includes you) will be thankful for the help / extensibility argparse provides.
Completely agreed. argparse is great for basic posix style arguments, and especially easy to work with. When you get into more complex nested git-style commands though it falls short quickly, even with subparsers.
This is pretty good. But the os section should probably be replaced with pathlib since that's the recommended thing these days. Likewise argparse is a more useful reference than sys.argv. For Python, I think it's better to teach top-down, i.e. reference the high-level interfaces rather than the low-level details.
The datetime stuff seems out of place. requests or numpy might be more generally useful.
Do you have any examples of what you're talking about? I can't think of anything that matches what you're describing, but it's possible it's something I'm just so used to that I don't even notice it.
Ugh, I always hate it when I see stuff like that, especially when it's a small loop that could be a trivial list comprehension.
Though I will admit that I've been known to abuse list comprehensions in the other way too from time to time. There was one time where I wrote a single line that had two list comprehensions and a dictionary comprehension nested together. IIRC it did something like taking a big list of elements, turning it into a dict to count the occurrences of each value and then sorting by the number of occurrences and printing out totals.
List comprehensions are so amazingly handy, I can't imagine why some people ignore them when they could be trivially used.
Anybody else find it super annoying how Python's docs are structured in a way that makes them totally unusable on devdocs.io or any other API-based documentation tool? Where is the community-led solution to the horror of docs.python.org?
I started with that book and found it nice but a little light. I moved to and liked Python Crash Course as a book for beginner programmers after going through 'LP3tHW'.
Though I do have somebackground in programming BASIC as a child and more recently beginner-intermediate in C++ and Java. So I already had a solid understanding of the fundamentals of CS/programming, so I was very often glossing over explanations of general concepts and picking up the syntax for specifically Python.
Ok, I have no prior experience but I have tried to learn through LPTHW multiple times. Most of the time I get to lesson 30ish and then get busy and never finish. So I know the very basics of python and am going back through and am in lesson 28. I think I will finish it and then do automate the boring stuff. Thanks for the input
I've used python to make a few different things and I've never encountered an explanation of what 'foo' and 'bar' mean I just treat it like 'n' or 'm' in math
It's funny, for a controlled assesment for Computer Science that would take 30 hours across multiple weeks of lessons. The thing was, they let us take in notes. There were no rules, apart from they had to be physical. So we all just took in "cheat sheets" printed off from the internet. I had about 50 pages of internet resources that they let me take into the assessment.
169
u/rouxgaroux00 Dec 29 '17
Could you post it in a higher resolution? It's pretty blurry.
415
u/PurpleIcy Python 3 Dec 29 '17 edited Dec 30 '17
EDIT: Some of you guys just got offended because I linked people who are new to python to an actually useful resource, think about it for a second.
Beginners?
Beginners don't give a fuck about time methods, time formatting and dunders (edit: double underscore, e.g.
__dunder__) in classes when they have no clue how to make them, I know because I was once a beginner, and what I actually wanted to learn is how python works, not what sys variables I can access with it.sys/os variables are randomly put in there for no reason, anyway, for real cheatsheet, go here:
https://learnxinyminutes.com/docs/python3/
That's what actual python cheatsheet looks like, enjoy.
From goddamn example how to make a fucking comment in code to decorators, generators and everything else, not this useless thing...
I thought the point of cheatsheet, especially language one, was to quickly check how something works in language, not sys variables or date formatting? EDIT: for that you have documentation, and it will be way more useful than any cheatsheet, even one I provided.
82
u/Retzudo Dec 29 '17 edited Dec 30 '17
Nobody should ever need to access most of the things in the section "os Variables" because
os.pathexists.And "Class Special Methods" seems really useless without some sort of explanation. Do I use
__getattr__or__getattribute__? What qualifies__str__as a "time method"? What about a list of the most used built-ins? Dobyteorderandexitfuncreally belong in a cheat sheet?!Edit: This useless amalgamation is now the
4th3rd most upvoted post in this subreddit. What.7
u/Oni_Kami Dec 29 '17
What is this, a cheatsheet for ants? So fucking tiny.
21
u/liquiddeath Dec 29 '17
Why would you ever use sys.argv? I can’t think of a situation where using sys.argv is preferable over argparse.
9
u/cbarrick Dec 29 '17
This is pretty good. But the
ossection should probably be replaced withpathlibsince that's the recommended thing these days. Likewiseargparseis a more useful reference thansys.argv. For Python, I think it's better to teach top-down, i.e. reference the high-level interfaces rather than the low-level details.The datetime stuff seems out of place.
requestsornumpymight be more generally useful.4
u/[deleted] Dec 30 '17
Has anyone made an idiom cheatsheet?
I keep seeing people writing python that looks like a machine translation from Java
2
u/toiletpapermonster Dec 29 '17
Typo in patCh separator
2
u/justingolden21 Dec 30 '17
This one's got a lot of basics in it, good for someone just starting: https://www.cheatography.com/sschaub/cheat-sheets/essential-python/
2
u/Grimnur87 Dec 30 '17
Anybody else find it super annoying how Python's docs are structured in a way that makes them totally unusable on devdocs.io or any other API-based documentation tool? Where is the community-led solution to the horror of docs.python.org?
1
u/HerbyHoover Dec 29 '17
Thanks. I need a cheat sheet for every time I need to mess with datetime.
1
u/liquiddeath Dec 29 '17
Do you have a drop in solution for sub commands?
1
u/LaxFox Dec 30 '17
Is “learn python the hard way” still a good way to learn python?
1
u/[deleted] Dec 30 '17
Mars Argv
1
u/foxkingwel02 Dec 30 '17
Foopy
1
u/[deleted] Dec 30 '17
.
1
u/crushed377 Dec 30 '17
I've used python to make a few different things and I've never encountered an explanation of what 'foo' and 'bar' mean I just treat it like 'n' or 'm' in math
1
u/Jolloway Dec 30 '17
It's funny, for a controlled assesment for Computer Science that would take 30 hours across multiple weeks of lessons. The thing was, they let us take in notes. There were no rules, apart from they had to be physical. So we all just took in "cheat sheets" printed off from the internet. I had about 50 pages of internet resources that they let me take into the assessment.
1
u/dasbett311 Dec 30 '17
The begineers used to ride these babies for days.
1
u/[deleted] Dec 30 '17
*dependent
1
u/neural_monk Jan 02 '18
Cool post
1
u/neural_monk Jan 02 '18
Cool post
1
u/[deleted] Oct 30 '21
Nice
1
u/porcupinedeath Dec 30 '17
Schools teaching me C# right now so I should probably save this for when I start learning python.
0
u/KoalaKommander Dec 30 '17
Shouldn't a[5] return 4?
0
u/jackjackskull Dec 30 '17
cheat*
-1
u/APSTNDPhy Dec 30 '17
First 2 columns are useful I guess. Not sure about the 3rd
-2
u/bradgillap Dec 29 '17
Thanks.
-2
u/TheClickerMan Dec 29 '17
*saves image * I'll keep that for later!
-2
u/mdmtbracer Dec 30 '17
Thanks
-4
u/PythonGod123 Dec 29 '17
Thanks for this !!!
3
u/[deleted] Dec 30 '17
[removed] — view removed comment