August 13, 2003
10 Python pitfalls
Hans Nowak has written an excellent article, 10 Python pitfalls.
Points 2, 3, 7 and 8 apply to Java as well as to Python.
It seems to me that the difference between mutable and immutable objects, which is a crucial one, is not given due prominence in any of the tutorials that I've seen, either for Python or Java.
Update: According to the Java Language Specification, point 3 does not apply to Java, i.e.
Posted to Python by Simon Brunning at August 13, 2003 10:39 AM
a = a + b is exactly the same as
a += b in all cases. If I'm reading it right, that is. I haven't got time to try this out now, though.
Java += behaviour is safe because it only applies to primitives because operators can only apply to primitives (and the String class of course, consistency? hah!) which are all immutable (as is String).
Of course I may be wrong, I often am.
I've made a similar mini-article myself. Rather than "pitfalls" its more - personal annoyances.