subprocess problem

eryk sun eryksun at gmail.com
Thu Feb 9 19:38:18 EST 2017


On Fri, Feb 10, 2017 at 12:05 AM, Wildman via Python-list
<python-list at python.org> wrote:
>
> Corrected code:
>
> def which(target)
>     for p in pathlist:
>         fullpath = p + "/" + target
>         if os.path.isfile(fullpath) and os.access(fullpath, os.X_OK):
>             return fullpath, True
>     return None, False

Use shutil.which:

https://docs.python.org/3/library/shutil.html#shutil.which



More information about the Python-list mailing list