Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77bb0f4

Browse files
committed
Backed out changeset 3d712292f2fa
1 parent e2d8bc5 commit 77bb0f4

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

Doc/tutorial/interpreter.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Using the Python Interpreter
1010
Invoking the Interpreter
1111
========================
1212

13-
The Python interpreter is usually installed as :file:`/usr/local/bin/python3.7`
13+
The Python interpreter is usually installed as :file:`/usr/local/bin/python3.6`
1414
on those machines where it is available; putting :file:`/usr/local/bin` in your
1515
Unix shell's search path makes it possible to start it by typing the command:
1616

1717
.. code-block:: text
1818
19-
python3.7
19+
python3.6
2020
2121
to the shell. [#]_ Since the choice of the directory where the interpreter lives
2222
is an installation option, other places are possible; check with your local
@@ -98,8 +98,8 @@ before printing the first prompt:
9898

9999
.. code-block:: shell-session
100100
101-
$ python3.7
102-
Python 3.7 (default, Sep 16 2015, 09:25:04)
101+
$ python3.6
102+
Python 3.6 (default, Sep 16 2015, 09:25:04)
103103
[GCC 4.8.2] on linux
104104
Type "help", "copyright", "credits" or "license" for more information.
105105
>>>
@@ -138,24 +138,25 @@ should follow. To display all these characters properly, your editor must
138138
recognize that the file is UTF-8, and it must use a font that supports all the
139139
characters in the file.
140140

141-
To declare an encoding other than the default one, a special comment line
142-
should be added as the *first* line of the file. The syntax is as follows::
141+
It is also possible to specify a different encoding for source files. In order
142+
to do this, put one more special comment line right after the ``#!`` line to
143+
define the source file encoding::
143144

144145
# -*- coding: encoding -*-
145146

146-
where *encoding* is one of the valid :mod:`codecs` supported by Python.
147+
With that declaration, everything in the source file will be treated as having
148+
the encoding *encoding* instead of UTF-8. The list of possible encodings can be
149+
found in the Python Library Reference, in the section on :mod:`codecs`.
147150

148-
For example, to declare that Windows-1252 encoding is to be used, the first
149-
line of your source code file should be::
151+
For example, if your editor of choice does not support UTF-8 encoded files and
152+
insists on using some other encoding, say Windows-1252, you can write::
150153

151154
# -*- coding: cp-1252 -*-
152155

153-
One exception to the *first line* rule is when the source code starts with a
154-
:ref:`UNIX "shebang" line <tut-scripts>`. In this case, the encoding
155-
declaration should be added as the second line of the file. For example::
156+
and still use all characters in the Windows-1252 character set in the source
157+
files. The special encoding comment must be in the *first or second* line
158+
within the file.
156159

157-
#!/usr/bin/env python3
158-
# -*- coding: cp-1252 -*-
159160

160161
.. rubric:: Footnotes
161162

0 commit comments

Comments
 (0)