ENV variable in Python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: ENV variable in Python (/thread-14550.html) |
ENV variable in Python - anandoracledba - Dec-05-2018 I have this simple code: #!/usr/bin/env python import sys, re, os NAS1=os.environ['NAS1'] print 'Value of NAS1: ' + NAS1 pwdfile='NAS1/admin/data/pswds' print 'Value of pwdfile: ' + pwdfileWhen I run this code, the "pwdfile" variable doesn't pick up the "NAS1" value from 2 lines above it. Expected output for 'pwdfile' = /u01/app/oracle/NAS1/admin/data/pswdsPlease help me understand what I am doing wrong here. Thanks in advance. RE: ENV variable in Python - Gribouillis - Dec-05-2018 Use pwdfile='{}/admin/data/pswds'.format(NAS1)Do you HAVE to use python 2? RE: ENV variable in Python - anandoracledba - Dec-06-2018 Thanks, Griboullis. I didn't even realize that I have been studying Python 2.7 when I started Python coding last week. Looks like I have to reset everything and start afresh with 3.7. Thanks so much for the pointer. |