@@ -101,11 +101,14 @@ with the *secondary prompt*, by default three dots (``...``). The interpreter
101101prints a welcome message stating its version number and a copyright notice
102102before printing the first prompt::
103103
104- python
105- Python 1.5.2b2 (#1, Feb 28 1999, 00:02:06) [GCC 2.8.1] on sunos5
106- Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
104+ $ python
105+ Python 3.0a1 (py3k, Sep 12 2007, 12:21:02)
106+ [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
107+ Type "help", "copyright", "credits" or "license" for more information.
107108 >>>
108109
110+ .. XXX update for final release of Python 3.0
111+
109112 Continuation lines are needed when entering a multi-line construct. As an
110113example, take a look at this :keyword: `if ` statement::
111114
@@ -170,44 +173,32 @@ The script can be given an executable mode, or permission, using the
170173Source Code Encoding
171174--------------------
172175
173- .. XXX out of date!
176+ By default, Python source files are treated as encoded in UTF-8. In that
177+ encoding, characters of most languages in the world can be used simultaneously
178+ in string literals, identifiers and comments --- although the standard library
179+ only uses ASCII characters for identifiers, a convention that any portable code
180+ should follow. To display all these characters properly, your editor must
181+ recognize that the file is UTF-8, and it must use a font that supports all the
182+ characters in the file.
174183
175- It is possible to use encodings different than ASCII in Python source files. The
176- best way to do it is to put one more special comment line right after the ``#! ``
177- line to define the source file encoding::
184+ It is also possible to specify a different encoding for source files. In order
185+ to do this, put one more special comment line right after the ``#! `` line to
186+ define the source file encoding::
178187
179188 # -*- coding: encoding -*-
180189
190+ With that declaration, everything in the source file will be treated as having
191+ the encoding *encoding * instead of UTF-8. The list of possible encodings can be
192+ found in the Python Library Reference, in the section on :mod: `codecs `.
181193
182- With that declaration, all characters in the source file will be treated as
183- having the encoding *encoding *, and it will be possible to directly write
184- Unicode string literals in the selected encoding. The list of possible
185- encodings can be found in the Python Library Reference, in the section on
186- :mod: `codecs `.
187-
188- For example, to write Unicode literals including the Euro currency symbol, the
189- ISO-8859-15 encoding can be used, with the Euro symbol having the ordinal value
190- 164. This script will print the value 8364 (the Unicode codepoint corresponding
191- to the Euro symbol) and then exit::
192-
193- # -*- coding: iso-8859-15 -*-
194-
195- currency = u"€"
196- print(ord(currency))
194+ For example, if your editor of choice does not support UTF-8 encoded files and
195+ insists on using some other encoding, say Windows-1252, you can write::
197196
198- If your editor supports saving files as ``UTF-8 `` with a UTF-8 *byte order mark *
199- (aka BOM), you can use that instead of an encoding declaration. IDLE supports
200- this capability if ``Options/General/Default Source Encoding/UTF-8 `` is set.
201- Notice that this signature is not understood in older Python releases (2.2 and
202- earlier), and also not understood by the operating system for script files with
203- ``#! `` lines (only used on Unix systems).
197+ # -*- coding: cp-1252 -*-
204198
205- By using UTF-8 (either through the signature or an encoding declaration),
206- characters of most languages in the world can be used simultaneously in string
207- literals and comments. Using non-ASCII characters in identifiers is not
208- supported. To display all these characters properly, your editor must recognize
209- that the file is UTF-8, and it must use a font that supports all the characters
210- in the file.
199+ and still use all characters in the Windows-1252 character set in the source
200+ files. The special encoding comment must be in the *first or second * line
201+ within the file.
211202
212203
213204.. _tut-startup :
0 commit comments