want move 1 directory given directory. achieve doing:
import os os.chdir(given_dir) os.chdir('..')
but, wondering if there better more explicit way using (ideally) 1 statement or if there exists built-in feature may not aware of.
how about
import os, os.path print os.chdir(os.path.join(given_dir, os.pardir))
or
os.chdir(os.path.dirname(given_dir))
(as selcuk suggested)
Comments
Post a Comment