I am stuck in an "error" during my folder creation. First of all, this is the code I am using:
import os
import errno
import subprocess
try:
folder = os.makedirs(os.path.expanduser('~\\Desktop\\FOLDER'))
except OSError as e:
if e.errno != errno.EEXIST:
raise
print(os.path.isdir('~\\Desktop\\FOLDER'), '- FOLDER CREATED')
So, the code do the following:
using
os.makedirs()
it creates a new folder on Desktop. I want to create a folder which use cross-platform path, so I am using~
symbolusing
print()
I want to verify that the folder really exist, that the directory is real. The output of this isTrue
orFalse
.
The problem is: if I am using the ~
symbol in print()
, the output is False
. If I put the complete path to the folder (ex: os.path.isdir('C:\\Users\\Bob\\Desktop\\FOLDER')
, the output is True
.
Why does this happen ? The folder is really created even if I have a False output ?