Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Function for the path of the script? Date: Tue, 29 Oct 2013 14:26:15 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 29 Message-ID: References: <00704f33-7e7f-4ccf-b28b-69776d2e237d@googlegroups.com> NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1383056775 9806 64.122.56.22 (29 Oct 2013 14:26:15 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 29 Oct 2013 14:26:15 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:57920 On 2013-10-28, Ben Finney wrote: > Grant Edwards writes: > >> On 2013-10-27, Ben Finney wrote: >> >> > What workflow requires you to know the filename of the module, within >> > the module? >> >> If you have a utility that can be used to do several related things, >> one way to tell that utility which you want to do is with command line >> arguments. > > That's a case for inspecting the command line. > >> For example your utility checks sys.argv[1] for a command or option >> flag. Another way is to give the file multiple names, and check >> sys.argv[0] to see what name you've been invoked under. > > Exactly so. This isn't a use case for finding the filesystem location > of the module. Indeed. I was answering a question about a use case knowing the _filename_, not the path for the file. -- Grant Edwards grant.b.edwards Yow! I wonder if I should at put myself in ESCROW!! gmail.com