summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial/introduction.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-09-13 17:18:21 (GMT)
committerGeorg Brandl <georg@python.org>2008-09-13 17:18:21 (GMT)
commit5d955ed13e4489b229fd31135aaa9280835665be (patch)
treedbf87d436d01e9a251f011fb5282fd7b95213691 /Doc/tutorial/introduction.rst
parentd7b032841aba549f2ec532adcd83829d0126bf40 (diff)
downloadcpython-5d955ed13e4489b229fd31135aaa9280835665be.zip
cpython-5d955ed13e4489b229fd31135aaa9280835665be.tar.gz
cpython-5d955ed13e4489b229fd31135aaa9280835665be.tar.bz2
Forward-port of r66447.
Diffstat (limited to 'Doc/tutorial/introduction.rst')
-rw-r--r--Doc/tutorial/introduction.rst21
1 files changed, 16 insertions, 5 deletions
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index bc81d7a..57254db 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -13,9 +13,11 @@ end a multi-line command.
Many of the examples in this manual, even those entered at the interactive
prompt, include comments. Comments in Python start with the hash character,
-``#``, and extend to the end of the physical line. A comment may appear at
-the start of a line or following whitespace or code, but not within a string
+``#``, and extend to the end of the physical line. A comment may appear at the
+start of a line or following whitespace or code, but not within a string
literal. A hash character within a string literal is just a hash character.
+Since comments are to clarify code and are not interpreted by Python, they may
+be omitted when typing in examples.
Some examples::
@@ -96,6 +98,15 @@ A value can be assigned to several variables simultaneously::
>>> z
0
+Variables must be "defined" (assigned a value) before they can be used, or an
+error will occur::
+
+ >>> # try to access an undefined variable
+ ... n
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ NameError: name 'n' is not defined
+
There is full support for floating point; operators with mixed type operands
convert the integer operand to floating point::
@@ -290,7 +301,7 @@ omitted second index defaults to the size of the string being sliced. ::
>>> word[2:] # Everything except the first two characters
'lpA'
-Unlike a C string, Python strings cannot be changed. Assigning to an indexed
+Unlike a C string, Python strings cannot be changed. Assigning to an indexed
position in the string results in an error::
>>> word[0] = 'x'
@@ -409,8 +420,8 @@ About Unicode
.. sectionauthor:: Marc-Andre Lemburg <mal@lemburg.com>
-Starting with Python 3.0 all strings support Unicode.
-(See http://www.unicode.org/)
+Starting with Python 3.0 all strings support Unicode (see
+http://www.unicode.org/).
Unicode has the advantage of providing one ordinal for every character in every
script used in modern and ancient texts. Previously, there were only 256