modifying os.environ
Martin von Loewis
loewis at informatik.hu-berlin.de
Tue Apr 18 10:30:37 EDT 2000
quinn at zloty.ugcs.caltech.edu (Quinn Dunkan) writes:
> Is there any way to delete things from the environment in python? A
> look at os.py reveals that _Environ only overrides __setitem__ to
> putenv. So how do you *delete* environment values? perl does it,
> and a look at the source seems to indicate that it doodles with the
> C environ directly. So perhaps python needs a delenv _Environ can
> use or something, or implement os.environ in C?
Some systems provide unsetenv(3), but that is not generally available.
> Or perhaps there's a better way to do the (common) thing I'm trying
> to do: clean the environment to insure some minimum sane values. I
> can't make a copy of the environ and then pass to execve() since
> that doesn't help much for popen and system.
You could implement popen and system yourself, starting from popen2
(for example).
Regards,
Martin
More information about the Python-list
mailing list