How to determine environment

Skip Montanaro skip at mojam.com
Mon Aug 28 15:42:56 EDT 2000


    Rick> What's the best way to determine what environment a program is
    Rick> running in? I want the program to use Tkinter if in X and ncurses
    Rick> if run in a console.

Rick,

Try peeking at os.environ:

    >>> import os
    >>> os.environ.get("DISPLAY", "")
    ':0.0'

Docs here:

    http://www.python.org/doc/current/lib/os-procinfo.html

-- 
Skip Montanaro (skip at mojam.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list