[Python-checkins] python/dist/src/Lib getopt.py,1.21,1.22

Guido van Rossum guido@python.org
Mon, 29 Jul 2002 10:16:48 -0400


> > Hm.  That sounds like a bug.  There's code in os.py like this:
> >
> > try:
> >     putenv
> > except NameError:
> >     pass
> > else:
> >     ...Here os.environ is redefined so changes are propagated...
> >
> >     def getenv(key, default=None):
> >         return environ.get(key, default)
> >     __all__.append("getenv")
> >
> > If this doesn't define getenv for you, it must mean you don't have
> > putenv?
> 
> Correct. The environment isn't going to go anywhere for MacPython, it's 
> purely a convenience for use within Python, to forestall lots of special 
> case code.
> 
> > It looks like the definition of getenv (which could be simplified to
> > "getenv = environ.get" BTW) ought to be outside the try/except/else
> > block.
> 
> Alternatively os.py could grow code like
> if sys.platform == 'mac':
> 	def putenv(name, value):
> 		environ[name] = value

Hm.  I like outdenting the definition of getenv better.  Can you check
this in (since you're in a better position to test it on the Mac)?

--Guido van Rossum (home page: http://www.python.org/~guido/)