152015024128143245168232148039196038240039088173205162105045222219251169048213060106065
Expected Code Breaking
There are a couple of changes in Python 2.0 that you should be aware of because they could cause your current Python code to break.
It's not possible to have string exceptions anymore. All standard exceptions can only be classes from now on. The -X command line option has been removed.
The \x escape that you normally use for string literals now accepts only 2 hexadecimal digits, instead of reading everything that you inform and taking only the lowest 8-bit of the given value. Note that not many people knew about or used this fact, so it should not cause any significant breakage.
Prior to 2.0, there were some methods that accepted multiple arguments, and internally converted them to a tuple, such as the .append() method of a list object. Consequently, you could type lstobj.append(3,4,5). After release 2.0, you need to inform an additional pair of parenthesis in order to avoid raising a TypeError exception. Thus, the right syntax has become lstobj.append((3,4,5)). Note that there are a couple of methods that still work in both ways, such as the socket.connect(). Also note that the script Tools/scripts/checkappend.py can be used to catch most occurrences of this mistake.
When dealing with long integers, the str() function doesn't include the 'L'character anymore at the end of the string. Although, the repr() function still does. Therefore, if you cut the last position of our string in order to get rid of the 'L', you will now get rid of the last digit. So, be careful!
Talking about str() and repr(), they now use different formatting precision string. The former uses %.12g, and the latter uses %.17g. Consequently, repr() might sometimes return more decimal places.
And always remember that you can depend on the support of the Python community to help you out with problems that you can't easily solve. If you think your problem is a common or simple problem, try reading the list archives or asking questions in the mailing lists. If it seems to be a bug, look at the CVS tree to see whether it has been fixed. If not, you can report it.
Good luck in your Python Adventure!
| Last updated on 1/30/2002 Python Developer's Handbook, © 2002 Sams Publishing |
|