I spent over ten minutes trying to scare up the old instructions for what a minimal non-working example is and how to achieve one — and that’s knowing exactly what I was looking for. Clearly, it needs to sit somewhere more permanent — and my blog is as good a place as any.
Post a minimal non-working example, state your python version, your platform and what you expected to happen. Hint: if your example is over 6 lines long, it’s almost certainly not minimal. Actually, if it’s over 3 lines, there’s a good chance it’s not minimal.
“Platform” means your operating system, or if it’s Java, the Java version and source. Version is what you get when you “print sys.version”.
A minimal non-working example doesn’t contain any code that is not essential to trigger the problem you’re seeing. The point of this is lots of times when people are minimizing the code that doesn’t work, it’ll become apparent what went wrong — and if it doesn’t, it makes it easier on the people helping you, so they don’t get misled by irrelevant code.
Please note that the minimal non-working example should exhibit the *same* problem. That is, if we load it into our Python interpreter and it says “NameError: name ‘sys’ not defined” then we will explain to you that you forgot to import the sys module. Please take whatever example you intend to post and paste it into your Python interpreter.
While these rules seem like we’re anal, they are there for your benefit. We are a bunch of volunteers — nobody pays us to help people on #python. We would much rather help people which genuinely need some help which requires Python knowledge then merely somebody too lazy to do his own debugging.
- In the code that is central to the error, avoid using variables when hard coding strings will do.
- Remove any lines which don’t seem important
- Test the problem is still exhibited
- Test to see if there is a single line which when removed solves the problem/causes the problem
- Avoid definining classes or functions. Inline code.