The negation operator in Python is not. Therefore just replace your ! with not.
For your example, do this:
if not os.path.exists("/usr/share/sounds/blues") :
proc = subprocess.Popen(["mkdir", "/usr/share/sounds/blues"])
proc.wait()
For your specific example (as Neil said in the comments), you don't have to use the subprocess module, you can simply use os.mkdir() to get the result you need, with added exception handling goodness.
Example:
blues_sounds_path = "/usr/share/sounds/blues"
if not os.path.exists(blues_sounds_path):
try:
os.mkdir(blues_sounds_path)
except OSError:
# Handle the case where the directory could not be created.
os.mkdir()? - Neiltry: os.mkdir(path)and handle the error. If you check first ('look before you leap') someone else can create or delete that folder after your check (but before you create it), and there could still be an error. The check doesn't guarantee anything at the time of creation. This idea is sometimes called 'easier to ask forgiveness than permission'. Even better (but even more specific to this problem), you can doos.makedirs(path, exist_ok=True)to create the path and ignore aFileExistsError. - speedstyle