for i in range(len(x)):
print i, x[i]
Here you would rely on the fact that len(x) would return TypeError on an
unsized object. Or, the x[i] would return TypeError on an unsubscriptable
Either way, if Python would move towards a more pure OO paradigm, the
subscription would become a method and you should be able the turn the
allowed() into a simple check whether a method exists.
This brings to another point from the previous discussion with Steven. In
most cases when you decide to forego on the type checking, you will run into
either a TypeError or an AttributeError if the wrong object was passed in
(as Jack points out). In a more pure OO environment with a perfect
namespace, you would refer to a method that doesn't exist for that object
(given the wrong object was passed in).
Disclaimer: With a "pure OO paradigm" I refer to an environment solely based
on method lookup.