On Jun 27, 4:05 pm, "Joe P. Cool" <[EMAIL PROTECTED]> 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)
>

For one thing, the expression 'os.environ.keys' will yield a method
object (not a list, as you're probably expecting), but iterating over
a method as you did should produce an exception. If you want to get
the list of environment vars, you have to call the method, like
'os.environ.keys()'.

Also, aren't changes to environment vars supposed to be visible to
child processes anyway? Which one are you suggesting that behaves the
wrong way, 'os.environ.clear()' or 'del os.environ[key]'?

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to