Package: shlexwhichplus
Like shutil.which, but for all file types, and multiple results (if desired)pip install shlexwhichplusTested against Windows 10 / Python 3.10 / Anacondaimportshutilfromshlexwhichplusimportwhich_plusprint('_________________shutil.which')print(shutil.which('python.exe'))print(shutil.which('Python.exe'))print(shutil.which('output.avi'))print(shutil.which('output.avi')),print(shutil.which(b'teSt.txt'))print(shutil.which(b'teSt.txt'))print('_________________which_plus')print(which_plus('python.exe',mode='one',path=None))print(which_plus('Python.exe',mode='all',path=None))print(which_plus('output.avi',mode='all',path=None))print(which_plus('output.avi',mode='one',path=None))print(which_plus('api-ms-win-crt-conio-l1-1-0.dll',mode='one',path=None))print(which_plus('api-ms-win-crt-conio-l1-1-0.dll',mode='all',path=None))print(which_plus('Python.exe',mode='BLALBLALA',path=None))# one if mode not in [all,one]print(which_plus('TeST.txt',mode='all',path=None))print(which_plus('teSt.txt',mode='one',path=None))print(which_plus(b'teSt.txt',mode='all',path=None))print(which_plus(b'teSt.txt',mode='one',path=None))# output_________________shutil.whichC:\ProgramData\anaconda3\envs\dfdir\python.exeC:\ProgramData\anaconda3\envs\dfdir\Python.exeNoneNoneNoneNone_________________which_plusC:\ProgramData\anaconda3\envs\dfdir\python.exe['C:\\ProgramData\\anaconda3\\envs\\dfdir\\python.exe']['C:\\cprojekt\\output.avi','C:\\ProgramData\\anaconda3\\envs\\dfdir\\output.avi']C:\ProgramData\anaconda3\envs\dfdir\output.aviC:\ProgramData\anaconda3\envs\dfdir\api-ms-win-crt-conio-l1-1-0.dll['C:\\ProgramData\\anaconda3\\envs\\dfdir\\api-ms-win-crt-conio-l1-1-0.dll','C:\\Program Files\\Microsoft\\jdk-11.0.16.101-hotspot\\bin\\api-ms-win-crt-conio-l1-1-0.dll','C:\\ProgramData\\anaconda3\\envs\\dfdir\\Library\\bin\\api-ms-win-crt-conio-l1-1-0.dll','C:\\Program Files\\Eclipse Adoptium\\jdk-11.0.18.10-hotspot\\bin\\api-ms-win-crt-conio-l1-1-0.dll','C:\\Program Files\\Amazon Corretto\\jdk17.0.6_10\\bin\\api-ms-win-crt-conio-l1-1-0.dll']C:\ProgramData\anaconda3\envs\dfdir\python.exe['C:\\ProgramData\\anaconda3\\envs\\dfdir\\Library\\bin\\TeST.txt','C:\\ProgramData\\anaconda3\\envs\\dfdir\\TeST.txt','C:\\ProgramData\\anaconda3\\envs\\dfdir\\Scripts\\TeST.txt']C:\ProgramData\anaconda3\envs\dfdir\TeST.txt[b'C:\\ProgramData\\anaconda3\\envs\\dfdir\\Library\\bin\\TeST.txt',b'C:\\ProgramData\\anaconda3\\envs\\dfdir\\TeST.txt',b'C:\\ProgramData\\anaconda3\\envs\\dfdir\\Scripts\\TeST.txt']b'C:\\ProgramData\\anaconda3\\envs\\dfdir\\TeST.txt'Givenacommand,mode,andaPATHstring,returnthepathwhichconformstothegivenmodeonthePATH,orNoneifthereisnosuchfile.:paramcmd:Astringspecifyingthecommandtobesearched.:typecmd:str:parammode:AstringindicatingwhethertoreturnoneorallmatchesonthePATH.If'one',returnthefirstmatchfoundonthePATH.If'all',returnalistofallmatchesfoundonthePATH.Ifanyotherstring,modedefaultsto'one'.:typemode:str:parampath:Astringrepresentingthesearchpath.IfNone,usesthecurrentsystemPATHvariable.:typepath:str|None:return:Ifmodeis'one',returnsthefirstpathfoundtothegivencommand,orNoneifnotfound.Ifmodeis'all',returnsalistofallpathsfoundtothegivencommand,oranemptylistifnotfound.:rtype:strorlistofstr