elif isinstance(resource, basestring) and (SOURCE_RE.match(resource)
                or DATASET_RE.match(resource) or MODEL_RE.match(resource)
                or PREDICTION_RE.match(resource)
                or EVALUATION_RE.match(resource)):

like this?