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. 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.

Posted to Python by Simon Brunning at August 13, 2003 10:39 AM

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.


Posted by: Tom on August 13, 2003 01:43 PM

Makes sense to me, Tom.

Posted by: Simon Brunning on August 13, 2003 01:44 PM

I've made a similar mini-article myself. Rather than "pitfalls" its more - personal annoyances.

Python Annoyances

Posted by: Ashiro on September 26, 2005 04:36 PM
Post a comment

Email Address:



Remember info?