One gotcha that I had with Python 2.x is the way it handles divisions. If you try the following code on a Python 2.x interpreter:
While with Python 3.x you get:
Of course, the first example is C-like, while the second is what you'd expect from a non-typed language. To get the same result on Python 2.x you'd have to write:
Even this doesn't work:
float(3/4) #since the 3/4 is evaluated before the conversion
This actually made me waste 20 minutes debugging a program because the error just doesn't made any sense to me. I think this is the same gotcha as the article shows.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds