Skip to content

Commit 6431347

Browse files
authored
bpo-32613: Update window FAQ (GH-5552)
1 parent a757649 commit 6431347

File tree

3 files changed

+26
-45
lines changed

3 files changed

+26
-45
lines changed

Doc/faq/windows.rst

Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ obvious; otherwise, you might need a little more guidance.
2626
Unless you use some sort of integrated development environment, you will end up
2727
*typing* Windows commands into what is variously referred to as a "DOS window"
2828
or "Command prompt window". Usually you can create such a window from your
29-
Start menu; under Windows 7 the menu selection is :menuselection:`Start -->
30-
Programs --> Accessories --> Command Prompt`. You should be able to recognize
29+
search bar by searching for ``cmd``. You should be able to recognize
3130
when you have started such a window because you will see a Windows "command
3231
prompt", which usually looks like this:
3332

@@ -52,19 +51,19 @@ compiles it into bytecodes, and then executes the bytecodes to run your
5251
program. So, how do you arrange for the interpreter to handle your Python?
5352

5453
First, you need to make sure that your command window recognises the word
55-
"python" as an instruction to start the interpreter. If you have opened a
56-
command window, you should try entering the command ``python`` and hitting
54+
"py" as an instruction to start the interpreter. If you have opened a
55+
command window, you should try entering the command ``py`` and hitting
5756
return:
5857

5958
.. code-block:: doscon
6059
61-
C:\Users\YourName> python
60+
C:\Users\YourName> py
6261
6362
You should then see something like:
6463

6564
.. code-block:: pycon
6665
67-
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
66+
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
6867
Type "help", "copyright", "credits" or "license" for more information.
6968
>>>
7069
@@ -81,52 +80,33 @@ by entering a few expressions of your choice and seeing the results:
8180
'HelloHelloHello'
8281
8382
Many people use the interactive mode as a convenient yet highly programmable
84-
calculator. When you want to end your interactive Python session, hold the :kbd:`Ctrl`
85-
key down while you enter a :kbd:`Z`, then hit the ":kbd:`Enter`" key to get back to your
86-
Windows command prompt.
83+
calculator. When you want to end your interactive Python session,
84+
call the :func:`exit` function or hold the :kbd:`Ctrl` key down
85+
while you enter a :kbd:`Z`, then hit the ":kbd:`Enter`" key to get
86+
back to your Windows command prompt.
8787

8888
You may also find that you have a Start-menu entry such as :menuselection:`Start
89-
--> Programs --> Python 3.3 --> Python (command line)` that results in you
89+
--> Programs --> Python 3.x --> Python (command line)` that results in you
9090
seeing the ``>>>`` prompt in a new window. If so, the window will disappear
91-
after you enter the :kbd:`Ctrl-Z` character; Windows is running a single "python"
91+
after you call the :func:`exit` function or enter the :kbd:`Ctrl-Z`
92+
character; Windows is running a single "python"
9293
command in the window, and closes it when you terminate the interpreter.
9394

94-
If the ``python`` command, instead of displaying the interpreter prompt ``>>>``,
95-
gives you a message like::
95+
Now that we know the ``py`` command is recognized, you can give your
96+
Python script to it. You'll have to give either an absolute or a
97+
relative path to the Python script. Let's say your Python script is
98+
located in your desktop and is named ``hello.py``, and your command
99+
prompt is nicely opened in your home directory so you're seeing something
100+
similar to::
96101

97-
'python' is not recognized as an internal or external command, operable program or batch file.
102+
C:\Users\YourName>
98103

99-
or::
104+
So now you'll ask the ``py`` command to give your script to Python by
105+
typing ``py`` followed by your script path::
100106

101-
Bad command or filename
102107

103-
then you need to make sure that your computer knows where to find the Python
104-
interpreter. To do this you will have to modify a setting called PATH, which is
105-
a list of directories where Windows will look for programs.
106-
107-
You should arrange for Python's installation directory to be added to the PATH
108-
of every command window as it starts. If you installed Python fairly recently
109-
then the command ::
110-
111-
dir C:\py*
112-
113-
will probably tell you where it is installed; the usual location is something
114-
like ``C:\Python33``. Otherwise you will be reduced to a search of your whole
115-
disk ... use :menuselection:`Tools --> Find` or hit the :guilabel:`Search`
116-
button and look for "python.exe". Supposing you discover that Python is
117-
installed in the ``C:\Python33`` directory (the default at the time of writing),
118-
you should make sure that entering the command ::
119-
120-
c:\Python33\python
121-
122-
starts up the interpreter as above (and don't forget you'll need a ":kbd:`Ctrl-Z`" and
123-
an ":kbd:`Enter`" to get out of it). Once you have verified the directory, you can
124-
add it to the system path to make it easier to start Python by just running
125-
the ``python`` command. This is currently an option in the installer as of
126-
CPython 3.3.
127-
128-
More information about environment variables can be found on the
129-
:ref:`Using Python on Windows <setting-envvars>` page.
108+
C:\Users\YourName> py Desktop\hello.py
109+
hello
130110

131111
How do I make Python scripts executable?
132112
----------------------------------------
@@ -332,4 +312,3 @@ This is a mistake; the extension should be .TGZ.
332312
Simply rename the downloaded file to have the .TGZ extension, and WinZip will be
333313
able to handle it. (If your copy of WinZip doesn't, get a newer one from
334314
https://www.winzip.com.)
335-

Doc/tools/susp-ignored.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ faq/programming,,:chr,">=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,
1414
faq/programming,,::,for x in sequence[::-1]:
1515
faq/programming,,:reduce,"print((lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,"
1616
faq/programming,,:reduce,"Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,"
17-
faq/windows,,:bd8afb90ebf2,"Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32"
17+
faq/windows,,:d48eceb,"Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32"
1818
howto/curses,,:black,"colors when it activates color mode. They are: 0:black, 1:red,"
1919
howto/curses,,:red,"colors when it activates color mode. They are: 0:black, 1:red,"
2020
howto/curses,,:green,"2:green, 3:yellow, 4:blue, 5:magenta, 6:cyan, and 7:white. The"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Update the faq/windows.html to use the py command from PEP 397 instead of
2+
python.

0 commit comments

Comments
 (0)