[docs] [issue30677] Enhance documentation of os.mkdir()

R. David Murray report at bugs.python.org
Thu Jun 15 11:28:35 EDT 2017


R. David Murray added the comment:

We don't generally document all exceptions that a method can raise, only those that are relevant to its specific API.  In this case, documenting the exception answers the question, "what happens if the directory already exists?"  This question is relevant to the API since the other reasonable possibility is that it would act as if the mkdir had succeeded.  As for documenting OSError, I'm sure there are ways to get os.mkdir to raise an exception that is not an OSError.

However, there is an argument to be made for documenting FileNotFound: the other reasonable thing the function could do in that case would be to create all intermediate path parts, but it does not do that (you use os.makedirs for that).  Since os.makedirs is documented right after os.mkdir, I'm not sure it is worth adding, but one can make the argument :)

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30677>
_______________________________________


More information about the docs mailing list