surprising behaviour of os.environ.clear
Tim Roberts
timr at probo.com
Sat Jun 28 02:23:18 EDT 2008
Benjamin <musiccomposition at gmail.com> wrote:
>
>On Jun 27, 4:05 pm, "Joe P. Cool" <joe.p.c... at googlemail.com> wrote:
>> If I call os.environ.clear in a python program child processes still
>> see the deleted entries. But when I iterate over the keys like so
>>
>> names = os.environ.keys
>> for k in names:
>> del os.environ[k]
>>
>> then the entries are also deleted for the child processes. Where is
>> the difference? Is this a bug?
>> (Observed in Python 2.5.2)
>
>This is because of how os.environ is implement with a UserDict
>subclass.
Why? I mean, I can see that it happens, but I don't understand why being a
UserDict causes this.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list