user883807
user883807

Reputation:

How do you check if the PYTHONSTARTUP variable is defined?

I was looking at this Stack Overflow answer and in it the author says for the original poster to check if the PYTHONSTARTUP variable is defined. I looked around and can not find out how to check to see if it is defined.

How do you check to see if the PYTHONSTARTUP variable is defined?

Upvotes: 1

Views: 2084

Answers (2)

sje397
sje397

Reputation: 41852

Windows (cmd.exe):

echo %PYTHONSTARTUP%

Elsewhere (in a shell, e.g. bash):

echo $PYTHONSTARTUP

In Python:

import os
print(os.environ['PYTHONSTARTUP'])

Upvotes: 1

Chewie
Chewie

Reputation: 7235

I assume it's an environment variable.

import os

if os.getenv("PYTHONSTART"):
    do_something()

Upvotes: 0

Related Questions