0

I am using os module to get environment variable . My Variable contains ${NAME} in it. So when I try to getting value using os.environ.get(VALUE1) , the value gets expanded and I am not getting the desired value.

For example i did :

export VALUE1="www.xyz.new${NAME}.com"

then when i try to get this value in my code

os.environ.get('VALUE1')

I get www.xyz.new.com when should get www.xyz.new${NAME}.com

how can i avoid this expansion and get the value as it is defined in env variable

Shane Warne
  • 1,350
  • 11
  • 24
  • The variable was expanded when you assigned it. – Barmar Apr 08 '20 at 18:46
  • 2
    `${NAME}` *isn't* part of the value; the shell expanded it before assigning the resulting string to `VALUE1`. You probably wanted `export VALUE1='www.xyz.new${NAME}.com'` (single quotes) – chepner Apr 08 '20 at 18:47
  • 2
    Also you shouldn't have spaces in the variable assignment. – Barmar Apr 08 '20 at 18:47
  • yes i have edited that part . it is assigned without spaces. this value is coming from userdata in the instance . i dont have an option to export with single quotes . – Shane Warne Apr 08 '20 at 18:50

0 Answers0