Tim Pinkawa wrote:
> def which(file):
>     for path in os.environ["PATH"].split(":"):
>             if file in os.listdir(path):
>                     print "%s/%s" % (path, file)

"if file in os.list()" is slow and not correct. You have to check if the
file is either a real file or a symlink to a file and not a directory or
special. Then you have to verify that the file has the executable bit, too.

Christian

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to