On Nov 8, 10:20 am, walterbyrd <[EMAIL PROTECTED]> wrote: > I have read that in Python 3.0, the following will raise an exception: > > >>> [2, 1, 'A'].sort() > > Will that raise an exception? And, if so, why are they doing this? How > is this helpful? Is this new "enhancement" Pythonic?
I realize that I am late to this discussion, but I would like to add something. I did not read all the replies, so please forgive me if the following points have already been made. This new behavior enhances the dynamic typing of Python and is very helpful for preventing hard-to-detect bugs. Let me give you an example of one such bug that cost me a significant amount of time a while back. I had a function that returned a number, and I meant to use it in a comparison test like this: if myfunc() < 0: ... Well, I mistakenly left off the parens: if myfunc < 0: ... Python just went ahead and did the comparison anyway. This sort of behavior is more like Perl, with its weak typing. It is not "Pythonic" in the sense of strong dynamic typing, without which Python would be much less powerful than it is. This kind of bug can be hard to detect, and I am glad that Python 3.0 prevents them. I wonder how much existing Python code has these kinds of bugs lurking. -- http://mail.python.org/mailman/listinfo/python-list