|| at Jun 25, 2010 at 12:25 pm
On Thu, 2010-06-24, Nobody wrote:
On Wed, 23 Jun 2010 17:27:16 -0500, Tim Daneliuk wrote:
Given a program 'foo' that takes a command line argument '-I
includefile', I want to be able to look for 'includefile' in a path
specified in an environment variable, 'FOOPATH'.
I'd like a semantic that says:
"If 'includefile' contains one or more path separator characters,
ignore 'FOOPATH'. If it contains no path separators, look for it in
the paths specified by 'FOOPATH', beginning with the leftmost path
Is there a standard Pythonic idiom for doing this or do I need to cook
up my own.
There isn't an idiom.
There are a surprising number of choices for such a simple task, e.g.
whether the search path is used for relative paths containing a separator,
whether you stop at the first file which exists or the first file which
meets other criteria (e.g. suitable permissions), whether default
locations come first or last, what happens if a default location is
included in the search path, etc.
Another favorite is whether relative paths are relative to your
current directory, or to the location of whatever file this is to be
For an example where it mattered (to C compilers), google for the
paper "recursive make considered harmful". It took compiler writers
decades to realize what the best choice was there.
(By the way, -I commonly means "search this directory for include
files" rather than "include this file". You may want to avoid
confusing people by choosing another letter, like -i.)
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .