Typechecking can be trivially defined in terms of adaptation:
def typecheck(x, T): y = adapt(x, T) if y is x: return y raise TypeError("...")
Assuming the type error displayed contains information on T, the caller can then trivially correct the type error by invoking adapt(arg, T) at the call point (assuming the argument actually *is* adaptable to the desired protocol). The code inside the function still gets to assume the supplied object has the correct type - the only difference is that if adaptation is actually needed, the onus is on the caller to provide it explicitly (and they will get a specific error telling them so).
This strikes me as quite an elegant solution.
Regards, Nick.
-- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com