Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e2d8bc52
Commit
e2d8bc52
authored
Feb 01, 2017
by
Mariatta Wijaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #29381: Clarify ordering of UNIX shebang line as source encoding line
parent
c6fe419d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
Doc/tutorial/interpreter.rst
Doc/tutorial/interpreter.rst
+14
-15
No files found.
Doc/tutorial/interpreter.rst
View file @
e2d8bc52
...
@@ -10,13 +10,13 @@ Using the Python Interpreter
...
@@ -10,13 +10,13 @@ Using the Python Interpreter
Invoking the Interpreter
Invoking the Interpreter
========================
========================
The Python interpreter is usually installed as :file:`/usr/local/bin/python3.
6
`
The Python interpreter is usually installed as :file:`/usr/local/bin/python3.
7
`
on those machines where it is available; putting :file:`/usr/local/bin` in your
on those machines where it is available; putting :file:`/usr/local/bin` in your
Unix shell's search path makes it possible to start it by typing the command:
Unix shell's search path makes it possible to start it by typing the command:
.. code-block:: text
.. code-block:: text
python3.
6
python3.
7
to the shell. [#]_ Since the choice of the directory where the interpreter lives
to the shell. [#]_ Since the choice of the directory where the interpreter lives
is an installation option, other places are possible; check with your local
is an installation option, other places are possible; check with your local
...
@@ -98,8 +98,8 @@ before printing the first prompt:
...
@@ -98,8 +98,8 @@ before printing the first prompt:
.. code-block:: shell-session
.. code-block:: shell-session
$ python3.
6
$ python3.
7
Python 3.
6
(default, Sep 16 2015, 09:25:04)
Python 3.
7
(default, Sep 16 2015, 09:25:04)
[GCC 4.8.2] on linux
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
...
@@ -138,25 +138,24 @@ should follow. To display all these characters properly, your editor must
...
@@ -138,25 +138,24 @@ should follow. To display all these characters properly, your editor must
recognize that the file is UTF-8, and it must use a font that supports all the
recognize that the file is UTF-8, and it must use a font that supports all the
characters in the file.
characters in the file.
It is also possible to specify a different encoding for source files. In order
To declare an encoding other than the default one, a special comment line
to do this, put one more special comment line right after the ``#!`` line to
should be added as the *first* line of the file. The syntax is as follows::
define the source file encoding::
# -*- coding: encoding -*-
# -*- coding: encoding -*-
With that declaration, everything in the source file will be treated as having
where *encoding* is one of the valid :mod:`codecs` supported by Python.
the encoding *encoding* instead of UTF-8. The list of possible encodings can be
found in the Python Library Reference, in the section on :mod:`codecs`.
For example,
if your editor of choice does not support UTF-8 encoded files and
For example,
to declare that Windows-1252 encoding is to be used, the first
insists on using some other encoding, say Windows-1252, you can writ
e::
line of your source code file should b
e::
# -*- coding: cp-1252 -*-
# -*- coding: cp-1252 -*-
and still use all characters in the Windows-1252 character set in the source
One exception to the *first line* rule is when the source code starts with a
files. The special encoding comment must be in the *first or second* line
:ref:`UNIX "shebang" line <tut-scripts>`. In this case, the encoding
within the file.
declaration should be added as the second line of the file. For example::
#!/usr/bin/env python3
# -*- coding: cp-1252 -*-
.. rubric:: Footnotes
.. rubric:: Footnotes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment