Discussion
I wonder a lot, "How do I subclass built-in types?"
There's a related question: "How do I figure out if something is sort of like a particular type?"
My goal is to take something, and say, "Does this act pretty much like an integer?" Or "does this act pretty much like a float?" Or "does this act pretty much like a dictionary?"
You could: count up all the behaviors you rely on. Then test if they all exist. If they all exist, consider that item a fit.
But, that seems really hard, if you've got a whole class with a ton of methods, all of which use the item. "Counting up" seems pretty hard in that case, and it seems like it would require a lot of discipline.
Is there, then, a set of tests that we can run over an item, to see if it acts "pretty much like" an int, a float, a dict, a string, blah blah blah...? (Or, at least supports the interface for all those things?)
What do people do about this?
Because I read all these things saying, "Don't use type!" "Don't use isInstance!" But I don't see much in the way of what to use.