parameters: (command, paths = None)
return_statement: return None
docstring: which(command, [paths]) - Look up the given command in the paths string
      (or the PATH environment variable, if unspecified).
docstring_summary: which(command, [paths]) - Look up the given command in the paths string
      (or the PATH environment variable, if unspecified).
docstring_tokens: which ( command [ paths ] ) - Look up the given command in the paths string ( or the PATH environment variable if unspecified ) .
function: def which(command, paths = None):
      """which(command, [paths]) - Look up the given command in the paths string
      (or the PATH environment variable, if unspecified)."""
  
      if paths is None:
          paths = os.environ.get('PATH','')
  
      # Check for absolute match first.
      if os.path.isfile(command):
          return command
  
      # Would be nice if Python had a lib function for this.
      if not paths:
          paths = os.defpath
  
      # Get suffixes to search.
      # On Cygwin, 'PATHEXT' may exist but it should not be used.
      if os.pathsep == ';':
          pathext = os.environ.get('PATHEXT', '').split(';')
      else:
          pathext = ['']
  
      # Search the paths...
      for path in paths.split(os.pathsep):
          for ext in pathext:
              p = os.path.join(path, command + ext)
              if os.path.exists(p) and not os.path.isdir(p):
                  return p
  
      return None
function_tokens: def which ( command , paths = None ) : if paths is None : paths = os . environ . get ( 'PATH' , '' ) # Check for absolute match first. if os . path . isfile ( command ) : return command # Would be nice if Python had a lib function for this. if not paths : paths = os . defpath # Get suffixes to search. # On Cygwin, 'PATHEXT' may exist but it should not be used. if os . pathsep == ';' : pathext = os . environ . get ( 'PATHEXT' , '' ) . split ( ';' ) else : pathext = [ '' ] # Search the paths... for path in paths . split ( os . pathsep ) : for ext in pathext : p = os . path . join ( path , command + ext ) if os . path . exists ( p ) and not os . path . isdir ( p ) : return p return None