Skip to content

Commit dcfea95

Browse files
committed
Update README.md
1 parent bf9437a commit dcfea95

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ for letter in string.letters:
1010
print("The letter at index %i is %s" % (i, letter))
1111
i = i + 1
1212
```
13+
1314
Bonus points for mentioning `enumerate` and use of `str.format`.
1415

1516
<div align="right">
@@ -42,6 +43,7 @@ With regard to the question of when using Python is the "right choice" for a pro
4243
For starters, if you know a language well, you know its drawbacks, so responses such as "there's nothing I don't like about it" or "it has no drawbacks" are very telling indeed.
4344

4445
The two most common valid answers to this question (by no means intended as an exhaustive list) are:
46+
4547
- The Global Interpreter Lock (GIL). CPython (the most common Python implementation) is not fully thread safe. In order to support multi-threaded Python programs, CPython provides a global lock that must be held by the current thread before it can safely access Python objects. As a result, no matter how many threads or processors are present, only one thread is ever being executed at any given time. In comparison, it is worth noting that the PyPy implementation discussed earlier in this article provides a stackless mode that supports micro-threads for massive concurrency.
4648
- Execution speed. Python can be slower than compiled languages since it is interpreted. (Well, sort of. See our earlier discussion on this topic.)
4749

@@ -80,25 +82,25 @@ Error Handling
8082

8183
Although Python 2 is formally considered legacy at this point,its use is still widespread enough that is important for a developer to recognize the differences between Python 2 and 3.
8284

83-
- Here are some of the key differences that a developer should be aware of:
84-
85-
- Text and Data instead of Unicode and 8-bit strings. Python 3.0 uses the concepts of text and (binary) data instead of Unicode strings and 8-bit strings. The biggest ramification of this is that any attempt to mix text and data in Python 3.0 raises a TypeError (to combine the two safely, you must decode bytes or encode Unicode, but you need to know the proper encoding, e.g. UTF-8)
86-
87-
- This addresses a longstanding pitfall for naïve Python programmers. In Python 2, mixing Unicode and 8-bit data would work if the string happened to contain only 7-bit (ASCII) bytes, but you would get UnicodeDecodeError if it contained non-ASCII values. Moreover, the exception would happen at the combination point, not at the point at which the non-ASCII characters were put into the str object. This behavior was a common source of confusion and consternation for neophyte Python programmers.
88-
89-
- `print` function. The print statement has been replaced with a print() function
90-
91-
- `xrange` – buh-bye. xrange() no longer exists (range() now behaves like xrange() used to behave, except it works with values of arbitrary size)
92-
93-
- API changes:
94-
- `zip()`, `map()` and `filter()` all now return iterators instead of lists.
95-
- `dict.keys()`, `dict.items()` and `dict.values()` now return 'views' instead of lists.
96-
- `dict.iterkeys()`, `dict.iteritems()` and `dict.itervalues()` are no longer supported.
97-
- Comparison operators. The ordering comparison operators (<, <=, >=, >) now raise a TypeError exception when the operands don't have a meaningful natural ordering. Some examples of the ramifications of this include:
98-
- Expressions like 1 < '', 0 > None or len <= len are no longer valid
99-
- None < None now raises a TypeError instead of returning False
100-
- Sorting a heterogeneous list no longer makes sense.
101-
- All the elements must be comparable to each other
85+
- Here are some of the key differences that a developer should be aware of:
86+
87+
- Text and Data instead of Unicode and 8-bit strings. Python 3.0 uses the concepts of text and (binary) data instead of Unicode strings and 8-bit strings. The biggest ramification of this is that any attempt to mix text and data in Python 3.0 raises a TypeError (to combine the two safely, you must decode bytes or encode Unicode, but you need to know the proper encoding, e.g. UTF-8)
88+
89+
- This addresses a longstanding pitfall for naïve Python programmers. In Python 2, mixing Unicode and 8-bit data would work if the string happened to contain only 7-bit (ASCII) bytes, but you would get UnicodeDecodeError if it contained non-ASCII values. Moreover, the exception would happen at the combination point, not at the point at which the non-ASCII characters were put into the str object. This behavior was a common source of confusion and consternation for neophyte Python programmers.
90+
91+
- `print` function. The print statement has been replaced with a print() function
92+
93+
- `xrange` – buh-bye. xrange() no longer exists (range() now behaves like xrange() used to behave, except it works with values of arbitrary size)
94+
95+
API changes:
96+
* `zip()`, `map()` and `filter()` all now return iterators instead of lists.
97+
* `dict.keys()`, `dict.items()` and `dict.values()` now return 'views' instead of lists.
98+
* `dict.iterkeys()`, `dict.iteritems()` and `dict.itervalues()` are no longer supported.
99+
* Comparison operators. The ordering comparison operators (<, <=, >=, >) now raise a TypeError exception when the operands don't have a meaningful natural ordering. Some examples of the ramifications of this include:
100+
* Expressions like 1 < '', 0 > None or len <= len are no longer valid
101+
* None < None now raises a TypeError instead of returning False
102+
* Sorting a heterogeneous list no longer makes sense.
103+
* All the elements must be comparable to each other
102104

103105
<div align="right">
104106
<b><a href="#">↥ back to top</a></b>

0 commit comments

Comments
 (0)