os.environ.copy()['COPY_HUH'] = "not really"

Terry Reedy tjreedy at udel.edu
Wed May 1 10:56:26 EDT 2002


"Jeff Epler" <jepler at unpythonic.net> wrote in message
news:mailman.1020257642.13347.python-list at python.org...
> On Tue, Apr 30, 2002 at 06:42:31PM -0300, Gustavo Niemeyer wrote:
> > >>> copy = os.environ.copy()
> > >>> print copy.__class__
> > os._Environ
> >
> > It's not a real dictionary, but an os._Environ class. Copying it
> > creates instances of the same class, and that class' behavior is
> > to insert the item in the environment. I belive this should be
> > avoided in this case, returning a true dictionary from copy().
I'll
> > send a patch to SourceForge, if you haven't done so yet.
>
> I was tempted to send a patch to SF, but I was worried that there
was
> some "good" reason for this feature.  Maybe it's just an accident
> waiting to be fixed after all.  If you have a patch prepared, by all
> means submit it.

I would normally expect a 'copy' to be a copy.
Perhaps os._Environ should have a .dict() method (if is does not now)
to do the conversion.






More information about the Python-list mailing list