I am trying to create a folder named ~/.Trash (its a hidden directory) without using FileExistsError. I want to create the directory without raising an error.
try:
  os.mkdir('~/.Trash')
except OSError as ex:
  if ex.errno == errno.EEXIST:
    print '' #I leave it blank
  else:
    raise
But I am getting the following error:
OSError: [Error 2] No such file or directory '~/.Trash' 
How can I create a directory protecting against FileExistsError?
 
    