Why python uppercases all environment variables in windows

前端 未结 2 1218
暗喜
暗喜 2021-01-19 22:14

Is there any reason why os.environ contains all environment variables uppercase on Windows?, I don\'t understand why (only on windows) it doesn\'t load them on using the sam

2条回答
  •  醉酒成梦
    2021-01-19 22:51

    Windows case insensitivity is a pain. Why would they do that? You can understand why searches should be case insensitive, but in most cases defined content should keep the exact value. Why? Well from experience it causes so many problems. I've never come across an issue where I've thought, "oh why wasn't that uppercased or lowercased?".

    From a Python point of view, why would they do that? Windows stores the key case sensitively, I'm guessing it is only some functions that get the value in a case insensitive manner, because I know for a fact that not all access functions do. I think MKS can tell the difference.

    Don't force platform specific behaviour (and be careful with forcing other behaviour) in an interface. Provide an alternative method to force case insensitivity, if required.

提交回复
热议问题