Python Doc Error: os.makedirs

Thomas Bellman bellman at lysator.liu.se
Wed Oct 19 22:16:48 CEST 2005


I wrote:

>    try:
>	os.makedirs("/tmp/trh/spam/norwegian/blue/parrot/cheese")
>    except os.error, e:
>	if e.errno != errno.EEXIST:
>	    raise

Actually, when I think more about it, one would probably rather
want something like:

    try:
	os.makedirs("/tmp/trh/spam/norwegian/blue/parrot/cheese")
    except os.error, e:
	if ( e.errno != errno.EEXIST  or
	     not os.path.isdir("/tmp/trh/spam/norwegian/blue/parrot/cheese")):
	    raise


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"Beware of bugs in the above code; I have    !  bellman @ lysator.liu.se
 only proved it correct, not tried it."      !  Make Love -- Nicht Wahr!



More information about the Python-list mailing list