Strange result on os.environ

Gonçalo Rodrigues op73418 at mail.telepac.pt
Thu May 16 11:22:50 EDT 2002


Hi,

os.environ is supposed to be a mapping with keys the environment
variables. Then what does it mean the following?

PythonWin 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on
win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond at skippinet.com.au) -
see 'Help/About PythonWin' for further copyright information.
>>> import os
>>> for key in os.environ:
... 	print key
... 	
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python22\lib\os.py", line 387, in __getitem__
    return self.data[key.upper()]
AttributeError: 'int' object has no attribute 'upper'
>>> 

If I do 

print os.environ

I get a nice (but long) string representing a dict with keys strings in
upper case. I'm using ActiveState Python distro (2.2.1) in win2k.

TIA and all the best,
Gonçalo Rodrigues



More information about the Python-list mailing list