Environment variables not visible from Python

Hegedüs, Ervin airween at gmail.com
Thu Sep 22 02:37:22 EDT 2011


hello,

On Thu, Sep 22, 2011 at 06:12:01AM +0000, Steven D'Aprano wrote:
> I don't understand why some environment variables are not visible from 
> Python.
> 
> [steve at wow-wow ~]$ echo $LINES $COLUMNS $TERM
> 30 140 xterm
> [steve at wow-wow ~]$ python2.6
> Python 2.6.6 (r266:84292, Dec 21 2010, 18:12:50)
> [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import os
> >>> (os.getenv('LINES'), os.getenv('COLUMNS'), os.getenv('TERM'))
> (None, None, 'xterm')

I think TERM is inherited from parent shell, but LINES and
COLUMNS are re-created every child shell. IMHO it's normally,
cause TERM will not change in child, but another variables should
changed...


Look at this:

airween at sebulba:~$ export LINES COLUMNS TERM
airween at sebulba:~$ python2.6
Python 2.6.6 (r266:84292, Mar 25 2011, 19:24:58) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> (os.getenv('LINES'), os.getenv('COLUMNS'), os.getenv('TERM'))
('65', '210', 'rxvt-256color')


a.
 



More information about the Python-list mailing list