Skip to content

Where is the _ environment variable documented? #129982

@yurivict

Description

@yurivict

When I run this script:

import os

for k,v in os.environ.items():
    print(f'key={k} val={v}')

it prints the environjment with an altered _ value.

The new _ value is:

key=_ val=/usr/local/bin/python3.11

while the original value was:

_=/usr/bin/env

Then this _ value alters the sys.path that Pyton uses in some way.

Is this behavior documented?

How to prevent _ from being altered when child Python processes are launched?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions