Python Glossary Русский

all Python 3Linux · macOSosfunction

os.confstr

os — configuration

Return a string system configuration value by name. Availability: Unix.

Syntax

os.confstr(...)

It returns a string, or None if the value is undefined. Names are listed in os.confstr_names and vary a lot between systems; CS_PATH, for example, gives the standard PATH for finding utilities. An unknown name raises ValueError. It rarely appears in teaching code.

Examples

import os
print(os.confstr('CS_PATH'))   # → ? только Unix: пути поиска стандартных утилит, например /bin:/usr/bin
print(os.confstr('CS_GNU_LIBC_VERSION'))   # → ? только Unix с glibc: версия libc, например glibc 2.36
print(os.confstr(os.confstr_names['CS_PATH']))   # → ? то же значение, что и по имени: принимается и числовой код из os.confstr_names
print(os.confstr('CS_XBS5_ILP32_OFF32_CFLAGS'))   # → ? None: имя известно, но значение в системе не определено
print(os.confstr('CS_НЕТ_ТАКОГО'))   # → ValueError: unrecognized configuration name

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy