[Tutor] path

Rick Pasotto rickp@telocity.com
Thu, 28 Feb 2002 22:13:36 -0500


On Thu, Feb 28, 2002 at 06:57:07PM -0800, Sean 'Shaleh' Perry wrote:
> 
> On 01-Mar-2002 kirk Bailey wrote:
> > ok, I want to have a program tell itself where it lives, so it can
> > figure out path information.  I want it to read a config file, but
> > it has to know where it is, and use that to read the config file, so
> > it knows where everything else is! 'pwd' in unix would work, and
> > mabe a few other things, but I do not seem to stumble over what is
> > needed to do this. when I tell it to just open the file 'foo.cf' it
> > stumbles, as when it tries to open './foo.cf'! Clue eagerly saught,
> > over.
> > 
> 
> check out the os and os.path modules.  Lots of path handlers there.

At least under unix the question is ill defined.

'pwd' returns the current directory, usually the directory the command
was executed in. This is not necessarily (and usually is not) where the
command program lives. And that is even less well defined. A file can
have many hard links and you can say it lives in *all* of them
simultaneously. A unix file is defined by its inode, not by its path
name.

Kirk needs to define his starting point by convention. Most unix config
file live in /etc or /usr/etc and/or $HOME.

-- 
"Once the principle of government -- judicial monopoly and the power
 to tax -- is incorrectly accepted as just, any notion of restraining
 government power and safeguarding individual liberty and property is
 illusory." -- Hans-Herman Hoppe
    Rick Pasotto    rickp@telocity.com    http://www.niof.net