Ernesto <[EMAIL PROTECTED]> wrote:
> NEVERMIND ! Here is the solution...
>
> #
> if (os.path.isdir("C:\\MyNewFolder") == 0):
> os.mkdir("C:\\MyNewFolder")
> # -
M
The corect way is to try os.mkdir, catch the exception and check the
errno value, which tell you why the call failed.
If the directory exists, you can ignore the exception, if its another
error, you usually had to raise it again and let the caller handle it.
Example:
import errno
try:
os.mkd
Ernesto wrote:
> I couldn't find this with a search, but isn't there a way to overwrite
> a previous folder (or at least not perform osmkdir( ) if your program
> detects it already exists). Thanks !
Would something like this help?
import os
def failsafe_mkdir(dirname):
try: os.mkdir
try os.path.exists(path)
-Larry Bates
Ernesto wrote:
> Ernesto wrote:
>> I couldn't find this with a search, but isn't there a way to overwrite
>> a previous folder (or at least not perform osmkdir( ) if your program
>> detects it already exists). Thanks !
>
> I suppose this also leads to the q
NEVERMIND ! Here is the solution...
#
if (os.path.isdir("C:\\MyNewFolder") == 0):
os.mkdir("C:\\MyNewFolder")
# -
thanks
--
http://mail.python.org/mailman/li
Ernesto wrote:
> I couldn't find this with a search, but isn't there a way to overwrite
> a previous folder (or at least not perform osmkdir( ) if your program
> detects it already exists). Thanks !
I suppose this also leads to the question of:
"Is there a way to determine if a path exists or n