July 21, 2010
12:37 a.m.
Steven D'Aprano wrote:
Perhaps all we need is a recipe in the docs:
try: os.makedirs(path) except OSError, e: if e.errno != 17: raise
I don't like writing code that depends on particular errno values, because I don't trust it to work cross- platform. Also it seems suboptimal to require people to use a recipe like this to get the behaviour that is wanted in the overwhelming majority of cases. I don't see what would be so bad about adding a new function for this. Think of it as correcting the mistake of not making makedirs() behave this way from the beginning. -- Greg