Merged revisions 82952,82954 via svnmerge from
[python/dscho.git] / Demo / scripts / makedir.py
blob7095868afc6a86b6f6bd5e1d7f4cf3f60a0fff98
1 #! /usr/bin/env python
3 # Like mkdir, but also make intermediate directories if necessary.
4 # It is not an error if the given directory already exists (as long
5 # as it is a directory).
6 # Errors are not treated specially -- you just get a Python exception.
8 import sys, os
10 def main():
11 for p in sys.argv[1:]:
12 makedirs(p)
14 def makedirs(p):
15 if p and not os.path.isdir(p):
16 head, tail = os.path.split(p)
17 makedirs(head)
18 os.mkdir(p, 0o777)
20 if __name__ == "__main__":
21 main()