@@ -150,8 +150,8 @@ Some well-known APIs no longer return lists:
150
150
sorted(d) `` instead (this works in Python 2.5 too and is just
151
151
as efficient).
152
152
153
- * Also, the :meth: `dict.iterkeys `, :meth: `dict.iteritems ` and
154
- :meth: `dict.itervalues ` methods are no longer supported.
153
+ * Also, the :meth: `! dict.iterkeys `, :meth: `! dict.iteritems ` and
154
+ :meth: `! dict.itervalues ` methods are no longer supported.
155
155
156
156
* :func: `map ` and :func: `filter ` return iterators. If you really need
157
157
a list and the input sequences are all of equal length, a quick
@@ -170,7 +170,7 @@ Some well-known APIs no longer return lists:
170
170
:func: `itertools.zip_longest `, e.g. ``map(func, *sequences) `` becomes
171
171
``list(map(func, itertools.zip_longest(*sequences))) ``.
172
172
173
- * :func: `range ` now behaves like :func: `xrange ` used to behave, except
173
+ * :func: `range ` now behaves like :func: `! xrange ` used to behave, except
174
174
it works with values of arbitrary size. The latter no longer
175
175
exists.
176
176
@@ -192,33 +192,33 @@ Python 3.0 has simplified the rules for ordering comparisons:
192
192
operators: objects of different incomparable types always compare
193
193
unequal to each other.
194
194
195
- * :meth: `builtin. sorted ` and :meth: `list.sort ` no longer accept the
195
+ * :meth: `sorted ` and :meth: `list.sort ` no longer accept the
196
196
*cmp * argument providing a comparison function. Use the *key *
197
197
argument instead. N.B. the *key * and *reverse * arguments are now
198
198
"keyword-only".
199
199
200
- * The :func: `cmp ` function should be treated as gone, and the :meth: `__cmp__ `
201
- special method is no longer supported. Use :meth: `__lt__ ` for sorting,
202
- :meth: `__eq__ ` with :meth: `__hash__ `, and other rich comparisons as needed.
203
- (If you really need the :func: `cmp ` functionality, you could use the
200
+ * The :func: `! cmp ` function should be treated as gone, and the :meth: `! __cmp__ `
201
+ special method is no longer supported. Use :meth: `~object. __lt__ ` for sorting,
202
+ :meth: `~object. __eq__ ` with :meth: `~object. __hash__ `, and other rich comparisons as needed.
203
+ (If you really need the :func: `! cmp ` functionality, you could use the
204
204
expression ``(a > b) - (a < b) `` as the equivalent for ``cmp(a, b) ``.)
205
205
206
206
Integers
207
207
--------
208
208
209
- * :pep: `237 `: Essentially, :class: `long ` renamed to :class: `int `.
209
+ * :pep: `237 `: Essentially, :class: `! long ` renamed to :class: `int `.
210
210
That is, there is only one built-in integral type, named
211
- :class: `int `; but it behaves mostly like the old :class: `long ` type.
211
+ :class: `int `; but it behaves mostly like the old :class: `! long ` type.
212
212
213
213
* :pep: `238 `: An expression like ``1/2 `` returns a float. Use
214
214
``1//2 `` to get the truncating behavior. (The latter syntax has
215
215
existed for years, at least since Python 2.2.)
216
216
217
- * The :data: `sys.maxint ` constant was removed, since there is no
217
+ * The :data: `! sys.maxint ` constant was removed, since there is no
218
218
longer a limit to the value of integers. However, :data: `sys.maxsize `
219
219
can be used as an integer larger than any practical list or string
220
220
index. It conforms to the implementation's "natural" integer size
221
- and is typically the same as :data: `sys.maxint ` in previous releases
221
+ and is typically the same as :data: `! sys.maxint ` in previous releases
222
222
on the same platform (assuming the same build options).
223
223
224
224
* The :func: `repr ` of a long integer doesn't include the trailing ``L ``
@@ -251,7 +251,7 @@ changed.
251
251
that uses Unicode, encodings or binary data most likely has to
252
252
change. The change is for the better, as in the 2.x world there
253
253
were numerous bugs having to do with mixing encoded and unencoded
254
- text. To be prepared in Python 2.x, start using :class: `unicode `
254
+ text. To be prepared in Python 2.x, start using :class: `! unicode `
255
255
for all unencoded text, and :class: `str ` for binary or encoded data
256
256
only. Then the ``2to3 `` tool will do most of the work for you.
257
257
@@ -269,7 +269,7 @@ changed.
269
269
separate *mutable * type to hold buffered binary data,
270
270
:class: `bytearray `. Nearly all APIs that accept :class: `bytes ` also
271
271
accept :class: `bytearray `. The mutable API is based on
272
- :class: `collections.MutableSequence `.
272
+ :class: `collections.MutableSequence <collections.abc.MutableSequence> `.
273
273
274
274
* All backslashes in raw string literals are interpreted literally.
275
275
This means that ``'\U' `` and ``'\u' `` escapes in raw strings are not
@@ -278,11 +278,11 @@ changed.
278
278
single "euro" character. (Of course, this change only affects raw
279
279
string literals; the euro character is ``'\u20ac' `` in Python 3.0.)
280
280
281
- * The built-in :class: `basestring ` abstract type was removed. Use
281
+ * The built-in :class: `! basestring ` abstract type was removed. Use
282
282
:class: `str ` instead. The :class: `str ` and :class: `bytes ` types
283
283
don't have functionality enough in common to warrant a shared base
284
284
class. The ``2to3 `` tool (see below) replaces every occurrence of
285
- :class: `basestring ` with :class: `str `.
285
+ :class: `! basestring ` with :class: `str `.
286
286
287
287
* Files opened as text files (still the default mode for :func: `open `)
288
288
always use an encoding to map between strings (in memory) and bytes
@@ -428,7 +428,7 @@ Changed Syntax
428
428
class C(metaclass=M):
429
429
...
430
430
431
- The module-global :data:`__metaclass__` variable is no longer
431
+ The module-global :data:`! __metaclass__` variable is no longer
432
432
supported. (It was a crutch to make it easier to default to
433
433
new-style classes without deriving every class from
434
434
:class:`object`.)
@@ -522,19 +522,19 @@ consulted for longer descriptions.
522
522
*encoding *, *errors *, *newline * and *closefd *. Also note that an
523
523
invalid *mode * argument now raises :exc: `ValueError `, not
524
524
:exc: `IOError `. The binary file object underlying a text file
525
- object can be accessed as :attr: `f.buffer ` (but beware that the
525
+ object can be accessed as :attr: `! f.buffer ` (but beware that the
526
526
text object maintains a buffer of itself in order to speed up
527
527
the encoding and decoding operations).
528
528
529
- * :ref: `pep-3118 `. The old builtin :func: `buffer ` is now really gone;
529
+ * :ref: `pep-3118 `. The old builtin :func: `! buffer ` is now really gone;
530
530
the new builtin :func: `memoryview ` provides (mostly) similar
531
531
functionality.
532
532
533
533
* :ref: `pep-3119 `. The :mod: `abc ` module and the ABCs defined in the
534
534
:mod: `collections ` module plays a somewhat more prominent role in
535
535
the language now, and built-in collection types like :class: `dict `
536
- and :class: `list ` conform to the :class: `collections.MutableMapping `
537
- and :class: `collections.MutableSequence ` ABCs, respectively.
536
+ and :class: `list ` conform to the :class: `collections.MutableMapping <collections.abc.MutableMapping> `
537
+ and :class: `collections.MutableSequence <collections.abc.MutableSequence> ` ABCs, respectively.
538
538
539
539
* :ref: `pep-3127 `. As mentioned above, the new octal literal
540
540
notation is the only one supported, and binary literals have been
@@ -612,7 +612,7 @@ review:
612
612
:mod: `!CGIHTTPServer `, :mod: `!SimpleHTTPServer `, :mod: `!Cookie `,
613
613
:mod: `!cookielib `).
614
614
615
- * :mod: `tkinter ` (all :mod: ` Tkinter `-related modules except
615
+ * :mod: `tkinter ` (all `` Tkinter ` `-related modules except
616
616
:mod: `turtle `). The target audience of :mod: `turtle ` doesn't
617
617
really care about :mod: `tkinter `. Also note that as of Python
618
618
2.6, the functionality of :mod: `turtle ` has been greatly enhanced.
@@ -628,47 +628,47 @@ Some other changes to standard library modules, not covered by
628
628
629
629
* Killed :mod: `!sets `. Use the built-in :func: `set ` class.
630
630
631
- * Cleanup of the :mod: `sys ` module: removed :func: `sys.exitfunc `,
632
- :func: `sys.exc_clear `, :data: `sys.exc_type `, :data: `sys.exc_value `,
633
- :data: `sys.exc_traceback `. (Note that :data: `sys.last_type `
631
+ * Cleanup of the :mod: `sys ` module: removed :func: `! sys.exitfunc `,
632
+ :func: `! sys.exc_clear `, :data: `! sys.exc_type `, :data: `! sys.exc_value `,
633
+ :data: `! sys.exc_traceback `. (Note that :data: `sys.last_type `
634
634
etc. remain.)
635
635
636
- * Cleanup of the :class: `array.array ` type: the :meth: `read ` and
637
- :meth: `write ` methods are gone; use :meth: `fromfile ` and
638
- :meth: `tofile ` instead. Also, the ``'c' `` typecode for array is
636
+ * Cleanup of the :class: `array.array ` type: the :meth: `! read ` and
637
+ :meth: `! write ` methods are gone; use :meth: `~array.array. fromfile ` and
638
+ :meth: `~array.array. tofile ` instead. Also, the ``'c' `` typecode for array is
639
639
gone -- use either ``'b' `` for bytes or ``'u' `` for Unicode
640
640
characters.
641
641
642
642
* Cleanup of the :mod: `operator ` module: removed
643
- :func: `sequenceIncludes ` and :func: `isCallable `.
643
+ :func: `! sequenceIncludes ` and :func: `! isCallable `.
644
644
645
645
* Cleanup of the :mod: `!thread ` module: :func: `!acquire_lock ` and
646
646
:func: `!release_lock ` are gone; use :meth: `~threading.Lock.acquire ` and
647
647
:meth: `~threading.Lock.release ` instead.
648
648
649
- * Cleanup of the :mod: `random ` module: removed the :func: `jumpahead ` API.
649
+ * Cleanup of the :mod: `random ` module: removed the :func: `! jumpahead ` API.
650
650
651
651
* The :mod: `!new ` module is gone.
652
652
653
- * The functions :func: `os.tmpnam `, :func: `os.tempnam ` and
654
- :func: `os.tmpfile ` have been removed in favor of the :mod: `tempfile `
653
+ * The functions :func: `! os.tmpnam `, :func: `! os.tempnam ` and
654
+ :func: `! os.tmpfile ` have been removed in favor of the :mod: `tempfile `
655
655
module.
656
656
657
657
* The :mod: `tokenize ` module has been changed to work with bytes. The
658
658
main entry point is now :func: `tokenize.tokenize `, instead of
659
659
generate_tokens.
660
660
661
- * :data: `string.letters ` and its friends (:data: `string.lowercase ` and
662
- :data: `string.uppercase `) are gone. Use
661
+ * :data: `! string.letters ` and its friends (:data: `! string.lowercase ` and
662
+ :data: `! string.uppercase `) are gone. Use
663
663
:data: `string.ascii_letters ` etc. instead. (The reason for the
664
- removal is that :data: `string.letters ` and friends had
664
+ removal is that :data: `! string.letters ` and friends had
665
665
locale-specific behavior, which is a bad idea for such
666
666
attractively named global "constants".)
667
667
668
- * Renamed module :mod: `__builtin__ ` to :mod: `builtins ` (removing the
669
- underscores, adding an 's'). The :data: `__builtins__ ` variable
668
+ * Renamed module :mod: `! __builtin__ ` to :mod: `builtins ` (removing the
669
+ underscores, adding an 's'). The :data: `! __builtins__ ` variable
670
670
found in most global namespaces is unchanged. To modify a builtin,
671
- you should use :mod: `builtins `, not :data: `__builtins__ `!
671
+ you should use :mod: `builtins `, not :data: `! __builtins__ `!
672
672
673
673
674
674
:pep: `3101 `: A New Approach To String Formatting
@@ -702,9 +702,9 @@ new powerful features added:
702
702
idiom for handling all exceptions except for this latter category is
703
703
to use :keyword: `except ` :exc: `Exception `.
704
704
705
- * :exc: `StandardError ` was removed.
705
+ * :exc: `! StandardError ` was removed.
706
706
707
- * Exceptions no longer behave as sequences. Use the :attr: `args `
707
+ * Exceptions no longer behave as sequences. Use the :attr: `~BaseException. args `
708
708
attribute instead.
709
709
710
710
* :pep: `3109 `: Raising exceptions. You must now use :samp: `raise
@@ -765,20 +765,20 @@ Operators And Special Methods
765
765
When referencing a method as a class attribute, you now get a plain
766
766
function object.
767
767
768
- * :meth: `__getslice__ `, :meth: `__setslice__ ` and :meth: `__delslice__ `
768
+ * :meth: `! __getslice__ `, :meth: `! __setslice__ ` and :meth: `! __delslice__ `
769
769
were killed. The syntax ``a[i:j] `` now translates to
770
- ``a.__getitem__(slice(i, j)) `` (or :meth: `__setitem__ ` or
771
- :meth: `__delitem__ `, when used as an assignment or deletion target,
770
+ ``a.__getitem__(slice(i, j)) `` (or :meth: `~object. __setitem__ ` or
771
+ :meth: `~object. __delitem__ `, when used as an assignment or deletion target,
772
772
respectively).
773
773
774
774
* :pep: `3114 `: the standard :meth: `next ` method has been renamed to
775
775
:meth: `~iterator.__next__ `.
776
776
777
- * The :meth: `__oct__ ` and :meth: `__hex__ ` special methods are removed
778
- -- :func: `oct ` and :func: `hex ` use :meth: `__index__ ` now to convert
777
+ * The :meth: `! __oct__ ` and :meth: `! __hex__ ` special methods are removed
778
+ -- :func: `oct ` and :func: `hex ` use :meth: `~object. __index__ ` now to convert
779
779
the argument to an integer.
780
780
781
- * Removed support for :attr: `__members__ ` and :attr: `__methods__ `.
781
+ * Removed support for :attr: `! __members__ ` and :attr: `! __methods__ `.
782
782
783
783
* The function attributes named :attr: `!func_X ` have been renamed to
784
784
use the :attr: `!__X__ ` form, freeing up these names in the function
@@ -802,7 +802,7 @@ Builtins
802
802
instance will automatically be chosen. With arguments, the behavior
803
803
of :func: `super ` is unchanged.
804
804
805
- * :pep: `3111 `: :func: `raw_input ` was renamed to :func: `input `. That
805
+ * :pep: `3111 `: :func: `! raw_input ` was renamed to :func: `input `. That
806
806
is, the new :func: `input ` function reads a line from
807
807
:data: `sys.stdin ` and returns it with the trailing newline stripped.
808
808
It raises :exc: `EOFError ` if the input is terminated prematurely.
@@ -820,31 +820,31 @@ Builtins
820
820
argument and a value of the same type as ``x `` when called with two
821
821
arguments.
822
822
823
- * Moved :func: `intern ` to :func: `sys.intern `.
823
+ * Moved :func: `! intern ` to :func: `sys.intern `.
824
824
825
- * Removed: :func: `apply `. Instead of ``apply(f, args) `` use
825
+ * Removed: :func: `! apply `. Instead of ``apply(f, args) `` use
826
826
``f(*args) ``.
827
827
828
828
* Removed :func: `callable `. Instead of ``callable(f) `` you can use
829
- ``isinstance(f, collections.Callable) ``. The :func: `operator.isCallable `
829
+ ``isinstance(f, collections.Callable) ``. The :func: `! operator.isCallable `
830
830
function is also gone.
831
831
832
- * Removed :func: `coerce `. This function no longer serves a purpose
832
+ * Removed :func: `! coerce `. This function no longer serves a purpose
833
833
now that classic classes are gone.
834
834
835
- * Removed :func: `execfile `. Instead of ``execfile(fn) `` use
835
+ * Removed :func: `! execfile `. Instead of ``execfile(fn) `` use
836
836
``exec(open(fn).read()) ``.
837
837
838
- * Removed the :class: `file ` type. Use :func: `open `. There are now several
838
+ * Removed the :class: `! file ` type. Use :func: `open `. There are now several
839
839
different kinds of streams that open can return in the :mod: `io ` module.
840
840
841
- * Removed :func: `reduce `. Use :func: `functools.reduce ` if you really
841
+ * Removed :func: `! reduce `. Use :func: `functools.reduce ` if you really
842
842
need it; however, 99 percent of the time an explicit :keyword: `for `
843
843
loop is more readable.
844
844
845
- * Removed :func: `reload `. Use :func: `!imp.reload `.
845
+ * Removed :func: `! reload `. Use :func: `!imp.reload `.
846
846
847
- * Removed. :meth: `dict.has_key ` -- use the :keyword: `in ` operator
847
+ * Removed. :meth: `! dict.has_key ` -- use the :keyword: `in ` operator
848
848
instead.
849
849
850
850
.. ======================================================================
0 commit comments