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

Steve Holden sholden at holdenweb.com
Wed May 1 12:46:40 EDT 2002


"Terry Reedy" <tjreedy at udel.edu> wrote in message
news:0AUz8.25621$Lj.1995635 at bin4.nnrp.aus1.giganews.com...
>
> "Alex Martelli" <aleax at aleax.it> wrote in message
> news:eCTz8.85568$vF6.2548577 at news2.tin.it...
> > Terry Reedy wrote:
> >         ...
> > > Perhaps os._Environ should have a .dict() method (if is does not
> now)
> > > to do the conversion.
> >
> > dict(os.environ) seems a better solution to me.  It's a general way
> to
> > make a dictionary from any generic mapping, after all.
>
> I thought of this and would agree if dict knows how to handle an
> os._Environ object, but I don't know if it does and am not prepared to
> test at the moment.
>

Looks like that's the way to go, then:

>>> type(os.environ)
<type 'instance'>
>>> e = dict(os.environ)
>>> e["TEMP"]
'C:\\DOCUME~1\\SHOLDEN\\LOCALS~1\\Temp'
>>>

regards
 Steve
--

Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/







More information about the Python-list mailing list