Python Glossary Русский

all Python 3platformfunction

platform.python_branch()

interpreter

The source-control branch the interpreter was built from, such as 'main' or 'tags/v3.14.0'; often an empty string.

Syntax

platform.python_branch()

Builds from Linux distributions and many installers carry no git information, so the function honestly returns ''. You therefore cannot rely on it to tell a release from a development build; use sys.version_info.releaselevel ('final', 'beta', 'alpha', 'candidate') for that.

Examples

import platform, sys
print(repr(platform.python_branch()))  # → ? например 'main' или ''
print(sys.version_info.releaselevel in {'alpha', 'beta', 'candidate', 'final'})  # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy