I can't iterate over os.environ, while a 'hand-made' dictionary works. It
works fine with python 2.2.3 under FreeBSD 4.8. I looked through the
release notes but didn't find anything I thought applied, so I guess I'd
just like to know if this is something peculiar to my system, or is it
more wide-spread? Here's what I get:
: molin$~; python
Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
[GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import os
>>> for k in os.environ:[/color][/color][/color]
.... print k
....
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
def __getitem__(sel f, key): return self.data[key]
KeyError: 0[color=blue][color=green][color=darkred]
>>> d = {}
>>> d['one'] = 1
>>> d['two'] = 2
>>> d['three'] = 3
>>> for k in d:[/color][/color][/color]
.... print k
....
three
two
one[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
--
Richard Kuhns rjkuhns@geetel. net
works fine with python 2.2.3 under FreeBSD 4.8. I looked through the
release notes but didn't find anything I thought applied, so I guess I'd
just like to know if this is something peculiar to my system, or is it
more wide-spread? Here's what I get:
: molin$~; python
Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
[GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import os
>>> for k in os.environ:[/color][/color][/color]
.... print k
....
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
def __getitem__(sel f, key): return self.data[key]
KeyError: 0[color=blue][color=green][color=darkred]
>>> d = {}
>>> d['one'] = 1
>>> d['two'] = 2
>>> d['three'] = 3
>>> for k in d:[/color][/color][/color]
.... print k
....
three
two
one[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
--
Richard Kuhns rjkuhns@geetel. net
Comment