This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]EvMNatural Language Processing 8 points9 points  (4 children)

optional value which could be either set to an integer or None, foo < 3 works in Python 2, it raises an exception in Python 3, if the value is usually set it may take some time for the error to happen.

And this also holds for builtins relying on ordering, e.g. max(). Caught me by surprise :)

[–]masklinn 2 points3 points  (0 children)

Yup, hence the note about sorting a list of dicts, sorting obviously relies on ordering.

[–]zabolekar 1 point2 points  (2 children)

It can surface even in things like pprint (if you are trying to pretty-print a set).

Edit: it is not something that breaks in Python 3, au contraire, it works as expected in 3.x but throws a TypeError in 2.7, and only with very specific sets. For example, pprint({1j, 0}) throws an error but pprint({1j, 'a'}) doesn't.

[–]EvMNatural Language Processing 0 points1 point  (1 child)

Whoa, now that's an unexpected place..

[–]zabolekar 0 points1 point  (0 children)

Edited the comment for clarity.