Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Referrer key missing form os.environ dictionary? Date: Thu, 26 Sep 2013 14:11:57 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 45 Message-ID: References: <5242f8bc$0$30000$c3e8da3$5496439d@news.astraweb.com> <52437bca$0$30000$c3e8da3$5496439d@news.astraweb.com> NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1380204717 1606 64.122.56.22 (26 Sep 2013 14:11:57 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Thu, 26 Sep 2013 14:11:57 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:54822 On 2013-09-26, Steven D'Aprano wrote: > On Wed, 25 Sep 2013 15:18:41 +0000, Grant Edwards wrote: > >>> The Referer is not an environment variable. >> >> It is when you're writing a CGI app. >> >>> How would your shell know what URL you were just browsing? >> >> Because the HTTP server sets those environment variables before invoking >> the CGI app. > > I stand corrected. > > That's a pretty shitty design though, isn't it? On a Unix system when you invoke a program, you "pass" it four things: 1) A dictionary where keys/values are both strings [enviornment variables] 2) A list of strings [command line args] 3) A set of open file descriptors. 4) The current working directory. You can provide input values to the program through any of these. For interactive programs, 2 and 3 are the most convenient. For programs intended to be invoked non-interactively via another program the first option can be very elegent and versatile -- but it does make use of the program interactively rather awkward. Semantically, passing values to a program via environment variables is very similar to keyword arguments to a Python function, while command line arguments are like positional arguments to a Python function. > Communicating via environment variables. What is this, 1998? :-) > > Mind you, I'm not sure what other alternatives exist. Command line arguments, open file descriptors, or files in the CWD. All are more difficult to use programmatically than environment variables. -- Grant Edwards grant.b.edwards Yow! I guess you guys got at BIG MUSCLES from doing too gmail.com much STUDYING!