1

I have a bash script and a python script:

script

#!/bin/bash
a=10
export a
python script.py

script.py

# access 'a' somehow

Is there a way to access the exported variables from python?

0

1 Answer 1

3

Exported variables are set as environment variables. Use os.environ (a dictionary) to read these in your Python script:

import os

a = os.environ['a']
Sign up to request clarification or add additional context in comments.

2 Comments

You can keep the upvote :)
@TomFenech: why thank you! I already hit the cap today, if that matters. :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.