Hi,
I'm looking for a Python library function that provides the same
functionality as the `which' command--namely, search the $PATH
variable for a given string and see if it exists anywhere within. I
currently examine the output from `which' itself, but I would like
something more portable. I
On Mon, Jun 29, 2009 at 12:54 PM, destroydestrooo...@gmail.com wrote:
Hi,
I'm looking for a Python library function that provides the same
functionality as the `which' command--namely, search the $PATH
variable for a given string and see if it exists anywhere within. I
currently examine
Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 12:54 PM, destroydestrooo...@gmail.com wrote:
Hi,
I'm looking for a Python library function that provides the same
functionality as the `which' command--namely, search the $PATH
variable for a given string and see if it exists anywhere within. I
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
On Mon, 29 Jun 2009 13:53:30 -0500, Tim Pinkawa wrote:
I'm looking for a Python library function that provides the same
functionality as the `which' command--namely, search the $PATH
variable for a given string and see if it exists anywhere within. I
currently examine the output from `which'
On 2009-06-29 14:31, Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 2:17 PM, Christian Heimesli...@cheimes.de wrote:
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
Tim Pinkawa wrote:
I realize four lines of Python does not replicate the functionality of
which exactly. It was intended to give the original poster something
to start with.
Agreed!
I am curious about it being slow, though. Is there a faster way to get
the contents of a directory than
On Mon, 29 Jun 2009 14:31:25 -0500, Tim Pinkawa wrote:
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.
I realize four
Robert Kern wrote:
On 2009-06-29 14:31, Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 2:17 PM, Christian Heimesli...@cheimes.de
wrote:
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
destroy wrote:
Hi,
I'm looking for a Python library function that provides the same
functionality as the `which' command--namely, search the $PATH
variable for a given string and see if it exists anywhere within. I
currently examine the output from `which' itself, but I would like
Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 2:17 PM, Christian Heimesli...@cheimes.de wrote:
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
11 matches
Mail list logo