Unused variable naming in python

This is a Python coding convention, yes. Best practice is to use _ where you don't care about the value being set, for example when unpacking values from a tuple. Sometimes, however, needing this is a sign you may be doing something else in a non-Pythonic way.

_ as a prefix is used to indicate "private" methods and variables, like Phil Cooper said. Use this to indicate that these methods are not part of any public contract other modules can or should rely on.

Some references:

  • What is the purpose of the single underscore "_" variable in Python?
  • Underscores as function prefixes
  • What is the meaning of a single- and a double-underscore before an object name?
  • Why does python use two underscores for certain things?

Not sure if this is a Eclipse thing or not, but I generally use '_' to denote values I don't care about (i.e., return values in tuples, or index values in for-loops).

Of course you can always resort to old stand-bys like naming variables dummy or ignore.

I'm not sure if PEP 8 mentions anything about this, might be worth peeking into.