SV: Running under Windows (basic level)

Gabriel Genellina gagsl-py2 at
Fri Feb 29 07:04:00 CET 2008

En Fri, 29 Feb 2008 02:30:43 -0200, K Viltersten <tmp1 at>  

>>> 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
>>>   but when i executed:
>> python
>> 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:

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\\"
>> or r"c:\loj\python\"...
> 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`, 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

More information about the Python-list mailing list