[Tutor] os.environ question

Alan Plum alan.plum at uni-koeln.de
Thu Nov 12 11:38:06 CET 2009


Ahoy!

On Do, 2009-11-12 at 06:34 +0300, Khalid Al-Ghamdi wrote:

> can anyone tell me why on python 2.6 i can enter os.environ and then
> get all the items that that pertain to the os while on python 3 you
> just get the following:
> <os._Environ object at 0x01B18D90>
> with no items?

Seems like os.environ has changed a little since Python 2.x. Try this:

>>> import os
>>> for env in os.environ:
...    print('%s: %s' % (env, os.environ[env]))

That should do the trick.

Cheers,

Alan




More information about the Tutor mailing list