Referrer key missing form os.environ dictionary?

Grant Edwards invalid at invalid.invalid
Thu Sep 26 10:11:57 EDT 2013


On 2013-09-26, Steven D'Aprano <steve+comp.lang.python at pearwood.info> 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!



More information about the Python-list mailing list