Os.supports_bytes_environ

Overview:

  • The os module provides the environment variables of the system as bytes(through os.environb) or as Unicode strings(through os.environ), except for the Windows operating system. In Windows, the collection of environment variables are dealt as Unicode strings(wchar_t of the windows operating system being the underlying). This behaviour is reflected through boolean flag supports_bytes_environ. The flag is set to False for Windows and assigned True otherwise. This is a low-level implementation detail which may change.

Example:

# Example program that demonstrates the usage of the 
# os.supports_bytes_environ Boolean variable
import os

print("Name of the os:%s"%os.name);    
print("Does the os support environment variables as bytes:%d"%os.supports_bytes_environ);    
print("Type of an item from the environment:");
print(type(os.environb.__getitem__("PATH".encode())));

Output:

Name of the os:posix

Does the os support environment variables as bytes:1

Type of an item from the environment:

<class 'bytes'>

 


Copyright 2024 © pythontic.com