Check if an object is order-able in python?

Posted by sortfiend on Stack Overflow See other posts from Stack Overflow or by sortfiend
Published on 2013-10-27T03:19:07Z Indexed on 2013/10/27 3:53 UTC
Read the original article Hit count: 89

Filed under:
|
|

How can I check if an object is orderable/sortable in Python?

I'm trying to implement basic type checking for the __init__ method of my binary tree class, and I want to be able to check if the value of the node is orderable, and throw an error if it isn't. It's similar to checking for hashability in the implementation of a hashtable.

I'm trying to accomplish something similar to Haskell's (Ord a) => etc. qualifiers. Is there a similar check in Python?

© Stack Overflow or respective owner

Related posts about python

Related posts about types