Notes
@@ -105,7 +105,7 @@ td pre{padding:0;border:0}
long data type
-Python 2 had separate int and long types for non-floating-point numbers. An int could not be any larger than sys.maxint, which varied by platform. Longs were defined by appending an L to the end of the number, and they could be, well, longer than ints. In Python 3, there is only one integer type, called int, which mostly behaves like the long type in Python 2. Since there are no longer two types, there is no need for special syntax to distinguish them.
+ Python 2 had separate int and long types for non-floating-point numbers. An int could not be any larger than sys.maxint, which varied by platform. Longs were defined by appending an L to the end of the number, and they could be, well, longer than ints. In Python 3, there is only one integer type, called int, which mostly behaves like the long type in Python 2. Since there are no longer two types, there is no need for special syntax to distinguish them.
Further reading: PEP 237: Unifying Long Integers and Integers.
@@ -160,7 +160,7 @@ td pre{padding:0;border:0}
has_key() dictionary method
-In Python 2, dictionaries had a has_key() method to test whether the dictionary had a certain key. In Python 3, this method no longer exists. Instead, you need to use the in operator.
+ In Python 2, dictionaries had a has_key() method to test whether the dictionary had a certain key. In Python 3, this method no longer exists. Instead, you need to use the in operator.
Notes
@@ -443,7 +443,7 @@ except ImportError:
next() iterator method
-In Python 2, iterators had a next() method which returned the next item in the sequence. That’s still true in Python 3, but there is now also a global next() function that takes an iterator as an argument.
+ In Python 2, iterators had a next() method which returned the next item in the sequence. That’s still true in Python 3, but there is now also a global next() function that takes an iterator as an argument.
Notes
@@ -667,7 +667,7 @@ reduce(a, b, c)
try...except statement
-The syntax for catching exceptions has changed slightly between Python 2 and Python 3.
+ The syntax for catching exceptions has changed slightly between Python 2 and Python 3.
Notes
@@ -718,7 +718,7 @@ except:
raise statement
-The syntax for raising your own exceptions has changed slightly between Python 2 and Python 3.
+ The syntax for raising your own exceptions has changed slightly between Python 2 and Python 3.
| Notes
@@ -1152,7 +1152,7 @@ except:
- Python 2.3 introduced the itertools module, which defined variants of the global zip(), map(), and filter() functions that returned iterators instead of lists. In Python 3, those global functions return iterators, so those functions in the itertools module have been eliminated.
+ Python 2.3 introduced the itertools module, which defined variants of the global zip(), map(), and filter() functions that returned iterators instead of lists. In Python 3, those global functions return iterators, so those functions in the itertools module have been eliminated. (There are still lots of useful functions in the itertools module, just not these.)
Notes
@@ -1213,7 +1213,7 @@ except:
os.getcwdu() function
-Python 2 had a function named os.getcwd(), which returned the current working directory as a (non-Unicode) string. Because modern file systems can handle directory names in any character encoding, Python 2.3 introduced os.getcwdu(). The os.getcwdu() function returned the current working directory as a Unicode string. In Python 3, there is only one string type (Unicode), so os.getcwd() is all you need.
+ Python 2 had a function named os.getcwd(), which returned the current working directory as a (non-Unicode) string. Because modern file systems can handle directory names in any character encoding, Python 2.3 introduced os.getcwdu(). The os.getcwdu() function returned the current working directory as a Unicode string. In Python 3, there is only one string type (Unicode), so os.getcwd() is all you need.
| Notes
@@ -1353,8 +1353,6 @@ do_stuff(a_list)
do_stuff(a_list)
|
|---|
-FIXME: once the rest of the book is written, this appendix should contain copious links back to any chapter or section that touches on these features.
-
☜ ☞
© 2001–9 Mark Pilgrim
|
|---|
|
|---|
|
|---|
|
|---|
|
|---|
|