sufficiently pythonic code for testing type of function
fredrik at pythonware.com
Wed Oct 11 07:30:40 CEST 2006
Theerasak Photha wrote:
> I wrote this for someone else to take an object and list of types,
> then check if obj is one of those types, raising an error otherwise.
note that a call to your function is pretty much equivalent to
assert isinstance(obj, types)
which has the additional advantage that you can provide a more specific
assert isinstance(obj, types), "message"
and also disable the check once you've verified that the code actually
does the right thing.
More information about the Python-list