Gnarlodious <gnarlodi...@gmail.com> writes:

> Hello, searched all over but no success. I want to have a script
> output HTML if run in a browser and plain text if run in a Terminal.
> In Python 2, I just said this:
>
> if len(sys.argv)==True:
>
> and it seemed to work. Py3 must have broken that by sending a list
> with the path to the script in BOTH the browser and Terminal. Is there
> some newfangled way to determine what is running the script (hopefully
> without a try wrapper)?

Your web server (assuming CGI) sets some environment variables, which
you could test for. This has as advantage (or disadvantage) that you can
set the variable at the CLI and see the output the browser could get.

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to