def parse_python_version(output):
    "Parse a Python version output returned by `python --version`.\n\n    Return a dict with three keys: major, minor, and micro. Each value is a\n    string containing a version part.\n\n    Note: The micro part would be `'0'` if it's missing from the input string.\n    "
    version_pattern = re.compile('\n        ^                   # Beginning of line.\n        Python              # Literally "Python".\n        \\s                  # Space.\n        (?P<major>\\d+)      # Major = one or more digits.\n        \\.                  # Dot.\n        (?P<minor>\\d+)      # Minor = one or more digits.\n        (?:                 # Unnamed group for dot-micro.\n            \\.              # Dot.\n            (?P<micro>\\d+)  # Micro = one or more digit.\n        )?                  # Micro is optional because pypa/pipenv#1893.\n        .*                  # Trailing garbage.\n        $                   # End of line.\n    ', re.VERBOSE)
    match = version_pattern.match(output)
    if (not match):
        return None
    return match.groupdict(default='0')
Parse a Python version output returned by `python --version`.

Return a dict with three keys: major, minor, and micro. Each value is a
string containing a version part.

Note: The micro part would be `'0'` if it's missing from the input string.
def parse_python_version(output):
    "Parse a Python version output returned by `python --version`.\n\n    Return a dict with three keys: major, minor, and micro. Each value is a\n    string containing a version part.\n\n    Note: The micro part would be `'0'` if it's missing from the input string.\n    "
    version_pattern = re.compile('\n        ^                   # Beginning of line.\n        Python              # Literally "Python".\n        \\s                  # Space.\n        (?P<major>\\d+)      # Major = one or more digits.\n        \\.                  # Dot.\n        (?P<minor>\\d+)      # Minor = one or more digits.\n        (?:                 # Unnamed group for dot-micro.\n            \\.              # Dot.\n            (?P<micro>\\d+)  # Micro = one or more digit.\n        )?                  # Micro is optional because pypa/pipenv#1893.\n        .*                  # Trailing garbage.\n        $                   # End of line.\n    ', re.VERBOSE)
    match = version_pattern.match(output)
    if (not match):
        return None
    return match.groupdict(default='0')