title: Should I raise ValueError or OSError for non-existent file arguments?
body: <p>When a program receives a filename argument that does not exist, or is not a directory, I want to raise an error. But what error is considered best practice? </p>
  
  <p>I understand that <code>ValueError</code> is often used to signal invalid arguments (and I've seen <a href="https://stackoverflow.com/q/1992006/699305">several</a> <a href="https://stackoverflow.com/q/256222/699305">questions</a> about it). I also understand that, especially after the reorganization of exceptions in Python 3.3 (<a href="https://www.python.org/dev/peps/pep-3151/" rel="nofollow noreferrer">PEP 3151</a>), <code>OSError</code> is the catch-all category for problems related to interaction with the system.</p>
  
  <p>So, I have a program that expects a filename argument. If the name supplied by the caller does not exist, or exists but is a directory, what error should I raise? It's an incorrect argument so it seems that <code>ValueError</code> applies; but if I try to read from it as a file, I will get an <code>OSError</code>-- so shouldn't this be returned for consistency?</p>