def addPrefixes(path, dirprefix):
 for folder in dirprefix:
  if (not folder):
   continue
  if (not path):
   break
  basepath = os.path.basename(os.path.abspath(path))
  if (folder != basepath.lower()):
   path = os.path.join(path, folder)
 return path

def addPrefixes ( path , dirprefix ) : for folder in dirprefix : if ( not folder ) : continue if ( not path ) : break basepath = os . path . basename ( os . path . abspath ( path ) ) if ( folder != basepath . lower ( ) ) : path = os . path . join ( path , folder ) return path
add list of prefixes as sub folders to path /my/path and [a .