def newdir(dirs):
 dirs = set(dirs)
 newdirs = set([i for i in os.listdir(dname) if (not os.path.isfile(os.path.join(dname, i)))])
 newdir = newdirs.difference(dirs)
 if (len(newdir) != 1):
  msg = "There was more than one directory created. Don't know what to delete."
  raise Exception(msg)
 newdir = newdir.pop()
 return newdir

def newdir ( dirs ) : dirs = set ( dirs ) newdirs = set ( [ i for i in os . listdir ( dname ) if ( not os . path . isfile ( os . path . join ( dname , i ) ) ) ] ) newdir = newdirs . difference ( dirs ) if ( len ( newdir ) != 1 ) : msg = "There was more than one directory created. Don't know what to delete." raise Exception ( msg ) newdir = newdir . pop ( ) return newdir
returns difference in directories between dirs and current directories if the difference is greater than one directory it raises an error .