Something strange with python 2.2.1 under RedHat 8.0
Fredrik Lundh
fredrik at pythonware.com
Thu Jun 26 13:43:45 EDT 2003
Peter Hansen wrote:
> > >>> for k in os.environ:
> > ... 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__(self, key): return self.data[key]
> > KeyError: 0
>
> Judging by the error message, os.environ is *not* a dict, but
> a UserDict. If it were to be subclassed from IterableUserDict
> instead, it would work okay I guess.
>
> Checking Python 2.2.2, I find it *is* now subclassed from
> IterableUserDict, so you're reporting a bug that is fixed
> in a later release. Please upgrade.
or use os.environ.keys(), like in the old days...
</F>
More information about the Python-list
mailing list