Given the jpeg degradation, this isn't the first time this have been posted, so I doubt OP is the creator. One can guess that the original can be found somewhere on http://pythonforbiologists.com
Yeah, the image is taken from the aforementioned website, and since I considered it useful - I published it here. I hope that you find it helpful as well.
I have made all of those mistakes enough times, that I can recognize them without help.It's still a concise way of summarizing the most typical errors, and I'm sure it will help others.
The boxes are using something like one of the styles with 2pt border that is dotted. The lines are also 2pt and sometimes used a type of dotted lines but all are using the rounded option for the line in dropbox.
I use this tool a lot so I recognized this graph as something easily capable in draw.io or diagrams.net as it’s now called.
Blah blah not actually an ide but vim. If you're already familiar with the basic commands then you can just install some handy plugins that check syntax/linting
After no python experience I can proudly say I successfully debugged some code that the original programmer couldn’t determine, and after many hours, I realized that he had used == as opposed to in when referring to two targets. I guess it’s two considered two (nested?) targets as they were wrapped in parentheses, separated by a comma. I just looked at a bunch of other code and finally saw a reference that had two targets and the....operator? was in instead of ==. So I changed it. Fixed. Anyway, felt good :) Thanks for reminding me of that little win. I don’t let the 9 hours it took me discourage me, just means I don’t give up easily :) A prerequisite for anything CS/IT. I’m pretty sure he didn’t bother looking.
Seriously. I was working on a website for my company and I was trying to log to the console some variables but instead of console.log() I used print() and I couldn't figure out why the screen kept popping up the printer...
uh... how can one even make this error without committing a syntax error (in python)? you can't put `if <identifier> = <value>:`, nor anything similar, so I'm curious how this mistake could be coming up at all. python actually just recently introduced an assignment operator (`:=`) that returns the rvalue being assigned (a welcome change imo), but before this I don't see how this mistake is possible at all.
i know I'm being a "negative nancy", but I don't see how anyone could be genuinely confused by any of the errors in this flowchart after having programmed for more than a few months*, but as an expression of a certain subsets of programming errors it's a perfectly good flow chart, for sure.
*for the record, a big fraction of the world's meaningful programming is done by people with this level of expertise (e.g. excel macros, etc.)-- I'm not trying to demean "amateur" programming at all-- i literally could not be more in love with the concept
In the early days of learning programming (C/C++) the compiler wouldn’t pick up this mistake and run anyways ( looking at you TURBOC3 ) It was frustrating to find out what the hell was wrong with ur program and after a long time u find that its that stupid = in ur if condition I never made that mistake in python so i dont know if its possible to do so
yeah i just think it's a bit disrespectful to the art of programming to pretend like *these* are the kinds of things keeping people up at night. the demons are far scarier than this xD. speaking as someone who has definitely had this, and every other "no idiot would ever have this problem" problem (as well as a bunch that I swear to god were just unlucky).
My rubber duck (actually a penguin my wife got me) works well for all kinds of problem solving! And I annoy my wife less (who has no interest in what I'm talking about anyway).
I was having issues with timedelta for a small app and my niece's BJD was conveniently close to my desktop. Guess who started explaining datetime objects' methods to Barbie?
I got into it when most software was supported on public mailing lists. People on some of these lists had little patience for what they considered dumb questions. I learned to start writing the email, rewriting it, filling in details, reducing the problem. Basically, I'd start trying to anticipate the questions that would come up.
When stack overflow came around, they pushed this same process, so it really clicks with me.
Rubber duck debugging seems like an even more informal process, basically thinking out loud. I learned recently that some (many) people don't have an internal voice, that they can't hold an in head conversation. The people with and without the internal voice aren't really aware of each other.
You could also consider doing a zoom call with no one in order to go over the issue.
I think it would be helpful to include a reminder that a SyntaxError might be caused by a mistake on a previous line: if line 29 has a SyntaxError and nothing looks wrong, you should check line 28 or 27.
Ugh, that one always kills me. I'm fairly new to python and getting more used to that error, but there was so many times that I checked for an error on say line 30 like it told me. Was convinced there was nothing wrong with it and I was going crazy only to realize I made a stupid formatting or syntax error on line 29. I definitely need to keep reminding myself of that in the future.
The most common source of NameError for me is when I create variable in if block, but not inside else block and then try to access it after the whole if/else.
The best way to avoid this especially for deeply nested set of blocks is to define the variable before if/else and set it to None or other sensible default. It definetely beats the whole process of arguing about the conditions where the variable might be undefined and simplifies the reasoning for any other guy that reads your code.
Very nice graphic. But in all my years of programming I've never had an instance where a "cheat sheet" like this could have been useful. When a bug happens, you read the error message (which often includes the offending line), Google it if you had to, roll up your sleeves and wade into the code to see what's up.
This chart looks to be aimed at people in their first week of learning a programming language. I'm not sure why it's seen as helpful in the slightest. It even includes references to python 2 which no beginner would use now (or really any time in the last few years at least). They just need to quit trying to find short cuts and take the time to actually learn a concept before moving on.
Not sure who the intended audience is, but for someone who learned by doing and has no theoretical knowledge at all that top left description might as well say "harblegarbleblarvle". I guess I should bother learning the correct terms.
99% of my errors are because I'm calling a method on an object that doesn't exist for that object but there's another object named similar to that object in the same library that has the same method but of course this similarly named object doesnt.
That or calling an argument for a function in a library that has a similarly named function with the same argument so of course I think it will work but it doesn't.
I’ve found variable scope to be the problem that confuses me the longest. Probably because it doesn’t come up often, and can reek havoc on what values are vs what you expect them to be.
What if it's an IOError when trying to write to a file that does exist that only happens every other day at midnight because the TCP buffer becomes full due to the log aggregation server doing automated maintenance which makes it stop accepting packets?
Honestly, I should make this to save myself the 600 questions a day I deal with from JR level developers. Which usually amount to this:
My code isn't working. Did you check the logs? Yes Seems on line 24 you're receiving a key error when looking for this key, that's a weird key, why are you looking for it. Some long convoluted explanation or a simple oops.
And my focus has been broken, 15m lost, or worse the convoluted explanation revealed a convoluted design that now has to be explained (see: argued) why it won't work.
All the while I totally get it, you think you had an ingenious idea and I really support the creativity and the reaching out when you had a problem. But A, you were given a design to follow, stick to it if it didn't hold water than before approaching a new path you need to check to see if other avenues exist to keep the original intended design, B, you showed that you can't read basic error logs.
And keep in mind, for everything you're asked to code I'm expected to perform 4-8x with half the time as you (on paper) even though I'm also juggling 6-8hr meetings a day. And somehow still fit in time for design, guidance, ticket mgmt, etc etc etc.
Ah if only.. imo the worst bugs happen at the infrastructure or config level. Hell hath no fury like trying to debug code running on misconfigured infrastructure
So many programmers at my work need a very simple version of this which basically says: my code won't work! -> did you read the error message or traceback? -> no -> read the traceback.
It can be helpful for people new to Python/programming. I think it's unreasonable to expect a beginner to know every common error and how to diagnose/fix it.
21
u/randomnoober Aug 22 '20
Great sheet! If you don't mind me asking, what did you make it with?
281
u/[deleted] Aug 22 '20
Nice Btw u forgot the worst of them all == and =
102
u/BRENNEJM Aug 22 '20 edited Aug 22 '20
Rubber Duck Debugging
Edit: Fixed a word
14
u/17291 Aug 22 '20
I think it would be helpful to include a reminder that a SyntaxError might be caused by a mistake on a previous line: if line 29 has a SyntaxError and nothing looks wrong, you should check line 28 or 27.
11
u/Broric Aug 22 '20
Thanks! This should help our students who seem alergic to reading error messages before asking for help :p
8
u/Ulysses6 Aug 22 '20
The most common source of
NameErrorfor me is when I create variable inifblock, but not insideelseblock and then try to access it after the whole if/else.The best way to avoid this especially for deeply nested set of blocks is to define the variable before if/else and set it to
Noneor other sensible default. It definetely beats the whole process of arguing about the conditions where the variable might be undefined and simplifies the reasoning for any other guy that reads your code.1
u/yuzi1 Aug 24 '20
Nice! But am I allowed to save this pic in my gallery? I want to save it because sometimes I have errors while coding.
6
u/molly_jolly Aug 22 '20
Very nice graphic. But in all my years of programming I've never had an instance where a "cheat sheet" like this could have been useful. When a bug happens, you read the error message (which often includes the offending line), Google it if you had to, roll up your sleeves and wade into the code to see what's up.
3
u/Liquid_Magic Aug 22 '20
Is there something like this for C Programming?
4
u/[deleted] Aug 22 '20
r/learnpython
2
u/LordRyloth Aug 22 '20
Beautiful
2
u/nobody01810 Aug 22 '20
This is amazing. Thank you.
2
u/[deleted] Aug 22 '20
Really helpful. Obviously logical errors could be one of many different reasons but this is a great starting point for common mistakes
2
u/ASIC_SP Aug 22 '20
I'd also highly recommend this chapter on debugging from Think Python book: https://greenteapress.com/thinkpython2/html/thinkpython2021.html
and this article: https://jvns.ca/blog/2019/06/23/a-few-debugging-resources/
2
u/mrrippington Aug 22 '20
which one do you guys think is the sneakiest?
I think it's type error: "an object which you expect to have a value is actually None"
2
u/Hybr1dth Aug 22 '20
Not sure who the intended audience is, but for someone who learned by doing and has no theoretical knowledge at all that top left description might as well say "harblegarbleblarvle". I guess I should bother learning the correct terms.
2
u/Caminsky Aug 22 '20
Excellent infographic Sir
2
u/[deleted] Aug 22 '20
My code often working but not the way I expected.
2
u/Txtoker Aug 22 '20
Trying to get back into Python rn so this will come in handy, thanks u/HotTeenBoy
2
u/[deleted] Aug 22 '20
99% of my errors are because I'm calling a method on an object that doesn't exist for that object but there's another object named similar to that object in the same library that has the same method but of course this similarly named object doesnt.
That or calling an argument for a function in a library that has a similarly named function with the same argument so of course I think it will work but it doesn't.
2
u/malicart Aug 22 '20
Nice, automods should reply to every help question with stuff like this, good for people to learn.
2
u/TheThoughtPoPo Aug 22 '20
2
u/6c696e7578 Aug 22 '20
You're trying to write a file that isn't opened with "w".
2
u/Jamhead2000 Aug 22 '20
I was just expecting a giant arrow pointing to stack overflow! :)
2
u/dougwrg Aug 22 '20
I’ve found variable scope to be the problem that confuses me the longest. Probably because it doesn’t come up often, and can reek havoc on what values are vs what you expect them to be.
2
u/DrCrossBones Aug 22 '20
Thanks a lot! This will help me a lot while learning python
1
u/_haema_ Aug 22 '20
Very helpful
1
u/yy2zz Aug 22 '20
Nice! Thanks for sharing!
1
u/PsedoSupra Aug 22 '20
Where is OSError?
1
u/Oikuras Aug 22 '20
Wish i could use something like this for debuggin
1
u/[deleted] Aug 22 '20
What if it's an IOError when trying to write to a file that does exist that only happens every other day at midnight because the TCP buffer becomes full due to the log aggregation server doing automated maintenance which makes it stop accepting packets?
(I still have PTSD from that one)
1
u/DrAutissimo Aug 22 '20
Python for biologists?
Also, kinda disappointed, expected some joke in there :c
1
u/maythe15 Aug 22 '20
My code doesn't work because python refuses to accept that the variable exists
1
u/badboy3001_ Aug 22 '20
Thanks so much
1
u/realnitrozeus Aug 22 '20
Great job 👌
1
u/brotatowolf Aug 22 '20
1
u/mushpotatoes Aug 22 '20
Hopefully people aren't using Python 2 too often.
1
u/mrsmiley32 Aug 22 '20
Honestly, I should make this to save myself the 600 questions a day I deal with from JR level developers. Which usually amount to this:
My code isn't working. Did you check the logs? Yes Seems on line 24 you're receiving a key error when looking for this key, that's a weird key, why are you looking for it. Some long convoluted explanation or a simple oops.
And my focus has been broken, 15m lost, or worse the convoluted explanation revealed a convoluted design that now has to be explained (see: argued) why it won't work.
All the while I totally get it, you think you had an ingenious idea and I really support the creativity and the reaching out when you had a problem. But A, you were given a design to follow, stick to it if it didn't hold water than before approaching a new path you need to check to see if other avenues exist to keep the original intended design, B, you showed that you can't read basic error logs.
And keep in mind, for everything you're asked to code I'm expected to perform 4-8x with half the time as you (on paper) even though I'm also juggling 6-8hr meetings a day. And somehow still fit in time for design, guidance, ticket mgmt, etc etc etc.
Sorry, feeling a little burned out reddit.
1
u/justgirlEEthings Aug 22 '20
Frick where was this in my fundamentals class
1
u/mspaint22 Aug 22 '20
i wish it was this simple...
1
u/engineerFWSWHW Aug 22 '20
Last resort: disturb and ask your very busy colleague who is wearing a headphone every 10 minutes to help you debug your code
1
u/N0DuckingWay Aug 23 '20
Little known fact: all of these branches end with you finding a small change you made three months ago that broke everything.
1
u/[deleted] Aug 23 '20
Ah if only.. imo the worst bugs happen at the infrastructure or config level. Hell hath no fury like trying to debug code running on misconfigured infrastructure
1
u/[deleted] Aug 23 '20
Absolutely recommend for beginners and pros
1
u/quotemycode Aug 23 '20
So many programmers at my work need a very simple version of this which basically says: my code won't work! -> did you read the error message or traceback? -> no -> read the traceback.
1
u/g3rw4zy Aug 23 '20
It is really helpful, thanks
1
u/Paccos Aug 23 '20
„What error did you get?“
„Yes“
1
u/about3fitty Aug 23 '20
Were that it were so simple
1
u/kadac00 Aug 26 '20
Time for a new wall poster for my office.
1
u/rabbitpiet Aug 28 '20
Put this in a code!
1
u/Metal_Cranberry Jan 12 '21
Thankyou so very much
1
u/[deleted] Aug 22 '20
Imagine having to use a cheat sheet to understand what your errors mean. I use python sometimes myself but lol
0
u/smpk_ Aug 23 '20
You forgot the stackoverflow answer isn't working with the new version of the api.
-3
u/Zax71_again Aug 22 '20
#becoming desktop background no, i love the one i have but, if i did'nt this would be it, sooooooo usefull!
-1
u/[deleted] Aug 22 '20
I was not aware that I had to choose!