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.

Is it enough to rely on side effects or absence thereof, or should I
put return True in here somewhere?

def test_obj_type(obj, types):
  for type in types:
    if isinstance(obj, type):
      break
    else:
      raise ValueError, 'object is not in %s' % types

-- Theerasak
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to