jvoisin wrote (06 Oct 2013 16:24:13 GMT) :
>> There's surely a nicer way to detect if a program is in the path,
>> isn't it?
> Not really :/
> shutil.which() is only available in Python 3.3
As much as I like using libraries, the which algorithm (in the case
when only a basename is given) is pretty trivial to implement.
How about simply stealing Python 3.3's version? Looks like that part
should be mostly enough:
seen = set()
for dir in path:
normdir = os.path.normcase(dir)
if not normdir in seen:
seen.add(normdir)
for thefile in files:
name = os.path.join(dir, thefile)
if _access_check(name, mode):
return name
return None
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]