Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54822

Re: Referrer key missing form os.environ dictionary?

From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Referrer key missing form os.environ dictionary?
Date 2013-09-26 14:11 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <l21fbd$1i6$1@reader1.panix.com> (permalink)
References (1 earlier) <mailman.315.1380117704.18130.python-list@python.org> <l1uqi7$qi5$1@dont-email.me> <5242f8bc$0$30000$c3e8da3$5496439d@news.astraweb.com> <l1uusg$k0t$1@reader1.panix.com> <52437bca$0$30000$c3e8da3$5496439d@news.astraweb.com>

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 15:45 +0300
  Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 16:14 +0300
  Re: Referrer key missing form os.environ dictionary? Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-09-25 16:01 +0200
    Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 17:04 +0300
      Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 14:26 +0000
        Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-25 15:04 +0000
          Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:16 +0300
            Re: Referrer key missing form os.environ dictionary? Tim Chase <python.list@tim.thechases.com> - 2013-09-25 10:42 -0500
            Re: Referrer key missing form os.environ dictionary? Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-25 21:17 +0000
        Re: Referrer key missing form os.environ dictionary? Ned Batchelder <ned@nedbatchelder.com> - 2013-09-25 11:09 -0400
      Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-25 14:52 +0000
        Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:02 +0300
          Re: Referrer key missing form os.environ dictionary? Xaxa Urtiz <urtizvereaxaxa@gmail.com> - 2013-09-25 08:09 -0700
          Re: Referrer key missing form os.environ dictionary? Tim Chase <python.list@tim.thechases.com> - 2013-09-25 10:14 -0500
            Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:35 +0300
        Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-25 15:18 +0000
          Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:41 +0300
            Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 16:27 +0000
            Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-25 18:37 +0000
          Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-26 00:11 +0000
            Re: Referrer key missing form os.environ dictionary? Terry Reedy <tjreedy@udel.edu> - 2013-09-25 21:32 -0400
            Re: Referrer key missing form os.environ dictionary? Chris Angelico <rosuav@gmail.com> - 2013-09-26 13:25 +1000
              Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-26 14:16 +0000
            Re: Referrer key missing form os.environ dictionary? Robert Kern <robert.kern@gmail.com> - 2013-09-26 11:15 +0100
            Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-26 14:11 +0000
              Re: Referrer key missing form os.environ dictionary? Chris Angelico <rosuav@gmail.com> - 2013-09-27 01:17 +1000
                Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-26 23:27 +0000
                Re: Referrer key missing form os.environ dictionary? Chris Angelico <rosuav@gmail.com> - 2013-09-27 16:01 +1000
    Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 17:07 +0300
      Re: Referrer key missing form os.environ dictionary? Robert Kern <robert.kern@gmail.com> - 2013-09-25 15:26 +0100
      Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 14:30 +0000
      Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-25 14:46 +0000
      Re: Referrer key missing form os.environ dictionary? Piet van Oostrum <piet@vanoostrum.org> - 2013-09-25 15:59 -0400
  Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 14:18 +0000
    Re: Referrer key missing form os.environ dictionary? Tim Chase <python.list@tim.thechases.com> - 2013-09-25 09:58 -0500

csiph-web