I am using Windows 7 with official Python 2.7.
On the cmd command line, I can write
python -c "import os; print os.environ['PATH'].split(';');"
However, this is not true:
C:\>python -c "import os; for p in os.environ['PATH'].split(';'): print p"
File "<string>", line 1
import os; for p in os.environ['PATH'].split(';'): print p
^
SyntaxError: invalid syntax
Can someone please help me? I really hope to write the importfollowing statements on the same line, because I would like to write a doskey command like this to make an easily readable PATH list:
doskey lpath=python -c "import os; for p in os.environ['PATH'].split(';'): print p"
source
share