Minimal Non-working Example

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.

Minimization tips:

  • 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.

“””

Advertisements

2 Responses to Minimal Non-working Example

  1. obviously i need to work on my SEO, because my post about this isn’t hit enough!

    i have been wanting to look at codepad.org to build a Minimal Non-working Example service, that basically acts like a quick-fix ticket system to demonstrate and collaborate on resolutions to problems. it would also make sure the examples actually produce the right errors, and thus that the examples are complete.

  2. moshez says:

    You are right.

    You need to work on your SEO.

    Pro-tip: learn about links.

    As in, link to your post about minimal non-working examples in your comment to generate more google juice…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: