surprising behaviour of os.environ.clear

Benjamin musiccomposition at gmail.com
Sat Jun 28 22:39:03 EDT 2008


On Jun 28, 1:23 am, Tim Roberts <t... at probo.com> wrote:
> Benjamin <musiccomposit... at gmail.com> wrote:
>
> >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.

The contents of a UserDict is stored in UserDict.data. When
UserDict.clear is called, that contents is simply cleared. environ
needs to override this is to unset env variable and then update the
actual dict.

> --
> Tim Roberts, t... at probo.com
> Providenza & Boekelheide, Inc.




More information about the Python-list mailing list