0

Why does this not print out 'xxx'?

$ SECRET_KEY='xxx' python -c 'import os; print os.environ['SECRET_KEY']'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'SECRET_KEY' is not defined
0

1 Answer 1

3

You're shell quoting is off and as a result, python sees:

import os; print os.environ[SECRET_KEY]

(note the missing quotes). This should work:

SECRET_KEY='xxx' python -c "import os; print os.environ['SECRET_KEY']"

should work.

Sign up to request clarification or add additional context in comments.

2 Comments

That's it. I need more coffee.
Try chai tea :-)... That's what I'm drinking (Yum!)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.