def dd_object_to_id(obj, obj_type, id_value='id'):
 if isinstance(obj, obj_type):
  return getattr(obj, id_value)
 elif isinstance(obj, basestring):
  return obj
 else:
  raise TypeError(('Invalid type %s looking for basestring or %s' % (type(obj).__name__, obj_type.__name__)))

def dd_object_to_id ( obj , obj_type , id_value = 'id' ) : if isinstance ( obj , obj_type ) : return getattr ( obj , id_value ) elif isinstance ( obj , basestring ) : return obj else : raise TypeError ( ( 'Invalid type %s looking for basestring or %s' % ( type ( obj ) . __name__ , obj_type . __name__ ) ) )
takes in a dd object or string and prints out its id this is a helper method .