[Tutor] Noob to Python - Need help with Variables
Tony Stevenson
Tony@pc-tony.com
Thu Jun 5 07:11:02 2003
Hi All,
I am completely new to programming, so I thought I would start with Python
as it comes highly reccomended, and have seen it do some very smart
things.
Anyway, I am trying to re-write our somewhat painful DOS Batch File
Logon Scripts.
I am currently using print os.environ["USERNAME"] to obtain the
username environment variable.
Now I will be using this entry several times throughout the script, so I
"thought" I would need to create a variable in python. But after trying
this
>>> user = "print os.environ['USERNAME']"
>>> print user
This is what is returned....
print os.environ['USERNAME']
So I can see that the "variable"??? user, it not executing the print
os.environ command. Instead is it using it as a text entry.
My question is how can I get this "user variable" to return the username
in question.
I think i may be missing a pair of quotes or something, but I am not too
sure...
Kind Regards,
Tony