Re: SV: Running test01.py under Windows (basic level)
- From: "Gabriel Genellina" <gagsl-py2@xxxxxxxxxxxx>
- Date: Fri, 29 Feb 2008 04:04:00 -0200
En Fri, 29 Feb 2008 02:30:43 -0200, K Viltersten <tmp1@xxxxxxxxxxxxxx> escribió:
I have v2.5.2 installed and i've composed
a source code i'm sure everybody will be
impressed by. It goes like this.
def bloppA ():
print "a very advanced piece of code"
What i get to work is to make it run from
the the snakes shell. Then, i realised
that such a masterpiece needs storing in
a file. So i saved it in a file called
great.py but when i executed:
python great.py
from the system prompt (cmd).
Or, if you are using IDLE ...
File -> Open, open your saved file, and use
the Run menu (or press F5).
There will be poking around with %PATH%, i can
tell. Never liked to do that under Windows.
No need to do that... Create an "alias.txt" file containing:
python=c:\path\to\your\python.exe $*
Execute (once, logged as administrator):
reg add "HKLM\SOFTWARE\Microsoft\Command Processor" /v AutoRun /t REG_SZ /d "doskey /macrofile=path\to\your\alias.txt"
Open a new cmd console. Typing python is enough to invoke the interpreter - no need to modify PATH.
Documentation for the DOSKEY command: http://technet2.microsoft.com/WindowsServer/en/library/f7f45601-5178-48c6-9219-51bd6f7abd3f1033.mspx
If you don't like the above recipe, create a "python.cmd" file containing:
@c:\path\to\your\python.exe %*
and save it somewhere in your PATH.
Beware of \ as it's the escape character, so
you have to use "c:\\loj\\python\\great.py"
or r"c:\loj\python\great.py"...
I've tried to add the extra backslashes (or "r"
attribute) but i still get the same error at
the colon. Should i understand that i made two
mistakes (the first being not using double "\"
and the second calling exec alltogether)?
exec is used to execute a string containing python code, not a file name. execfile does what you want, but don't use it. Either execute your program with `python name.py`, or load it into IDLE and run it with F5, or learn how to make your favorite IDE/text editor Python-aware (if supported).
have you worked out the Tutorial?
Not yet. I started off using some small things.
I tend to learn by doing. Or rather making. A
lot of errors, that is. :)
At least overview it. Python syntax is very clear and legible, so probably you can figure yourself a lot of things, but there are some important topics that you have to know and are explained in the Tutorial. It isn't very long.
--
Gabriel Genellina
.
- References:
- Running test01.py under Windows (basic level)
- From: K Viltersten
- Re: Running test01.py under Windows (basic level)
- From: Gabriel Genellina
- SV: Running test01.py under Windows (basic level)
- From: K Viltersten
- Running test01.py under Windows (basic level)
- Prev by Date: buy cheap tibia gold here gameotl.com
- Next by Date: Re: SV: Running test01.py under Windows (basic level)
- Previous by thread: SV: Running test01.py under Windows (basic level)
- Next by thread: SV: Running test01.py under Windows (basic level)
- Index(es):
Relevant Pages
|