Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 2:17 PM, Christian Heimes 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
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
something
Robert Kern wrote:
On 2009-06-29 14:31, Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 2:17 PM, Christian Heimes
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
On Mon, 29 Jun 2009 21:53:42 +0200, Christian Heimes wrote:
>> I am curious about it being slow, though. Is there a faster way to get
>> the contents of a directory than os.listdir() or is there a faster way
>> to see if an element is in a list other than "x in y"? I believe
>> 'which' will termin
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 reali
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 o
On 2009-06-29 14:31, Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 2:17 PM, Christian Heimes 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 t
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
On Mon, Jun 29, 2009 at 2:31 PM, Tim Pinkawa wrote:
> I am curious about it being slow, though. Is there a faster way to get
> the contents of a directory than os.listdir() or is there a faster way
> to see if an element is in a list other than "x in y"? I believe
> 'which' will terminate once it f
On Mon, Jun 29, 2009 at 2:17 PM, Christian Heimes 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 fou
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
Tim Pinkawa wrote:
On Mon, Jun 29, 2009 at 12:54 PM, 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 o
On Mon, Jun 29, 2009 at 12:54 PM, 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 `
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 loo
14 matches
Mail list logo