Commit 0df79794 authored by Georg Brandl's avatar Georg Brandl

#4000: fix several 2.x atavisms.

parent b186f343
...@@ -69,9 +69,9 @@ output must only depend on its input. ...@@ -69,9 +69,9 @@ output must only depend on its input.
Some languages are very strict about purity and don't even have assignment Some languages are very strict about purity and don't even have assignment
statements such as ``a=3`` or ``c = a + b``, but it's difficult to avoid all statements such as ``a=3`` or ``c = a + b``, but it's difficult to avoid all
side effects. Printing to the screen or writing to a disk file are side side effects. Printing to the screen or writing to a disk file are side
effects, for example. For example, in Python a ``print`` statement or a effects, for example. For example, in Python a call to the :func:`print` or
``time.sleep(1)`` both return no useful value; they're only called for their :func:`time.sleep` function both return no useful value; they're only called for
side effects of sending some text to the screen or pausing execution for a their side effects of sending some text to the screen or pausing execution for a
second. second.
Python programs written in functional style usually won't go to the extreme of Python programs written in functional style usually won't go to the extreme of
...@@ -1031,8 +1031,8 @@ value and an iterator for the elements with that key. ...@@ -1031,8 +1031,8 @@ value and an iterator for the elements with that key.
... ...
] ]
def get_state ((city, state)): def get_state (city_state):
return state return city_state[1]
itertools.groupby(city_list, get_state) => itertools.groupby(city_list, get_state) =>
('AL', iterator-1), ('AL', iterator-1),
......
...@@ -632,7 +632,7 @@ a fixed-width print format: ...@@ -632,7 +632,7 @@ a fixed-width print format:
... def __str__(self): ... def __str__(self):
... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) ... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
>>> for p in Point(3, 4), Point(14, 5/7.): >>> for p in Point(3, 4), Point(14, 5/7):
... print(p) ... print(p)
Point: x= 3.000 y= 4.000 hypot= 5.000 Point: x= 3.000 y= 4.000 hypot= 5.000
Point: x=14.000 y= 0.714 hypot=14.018 Point: x=14.000 y= 0.714 hypot=14.018
......
...@@ -126,7 +126,7 @@ for file objects could be added:: ...@@ -126,7 +126,7 @@ for file objects could be added::
if obj.name in ['<stdin>', '<stdout>', '<stderr>']: if obj.name in ['<stdin>', '<stdout>', '<stderr>']:
return obj.name return obj.name
else: else:
return `obj` return repr(obj)
aRepr = MyRepr() aRepr = MyRepr()
print aRepr.repr(sys.stdin) # prints '<stdin>' print aRepr.repr(sys.stdin) # prints '<stdin>'
......
...@@ -676,8 +676,8 @@ Delimiters ...@@ -676,8 +676,8 @@ Delimiters
The following tokens serve as delimiters in the grammar:: The following tokens serve as delimiters in the grammar::
( ) [ ] { } @ ( ) [ ] { }
, : . ` = ; , : . ; @ =
+= -= *= /= //= %= += -= *= /= //= %=
&= |= ^= >>= <<= **= &= |= ^= >>= <<= **=
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment