I am a habitual wheel re-inventor, so it would not surprise me, but I made
this little function that I was kinda proud of (seeing that I have only
been learning python like a week now):

It just takes a directory and checks to see if all the directories,
sub-directories exist and creates them if they don't:

def insure_exists_dir(dir):
  grow_path = [dir]
  while not os.path.ismount(grow_path[0]):
    part_tuple = os.path.split(grow_path[0])
    grow_path.insert(0, part_tuple[0])

  del(grow_path[0])
  while grow_path:
    if not os.path.exists(grow_path[0]):
      os.mkdir(grow_path[0])
    del(grow_path[0])
  return(dir)


Opinions?  What should I really be using?

-- 
Mark :)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to