to_concept
relationalai.semantics.inspect
to_concept(obj: Variable, default: object = _MISSING) -> Concept | AnyReturn the Concept that obj resolves to.
Works on any DSL Variable — Concept, Chain,
Expression, Ref, FieldRef, etc.
Parameters
(objVariable) - Any DSL variable or expression.
(defaultobject, default:_MISSING) - Value to return if the concept cannot be determined. If omitted, aTypeErroris raised instead.
Returns
Concept- The resolved concept, or default if the concept cannot be determined and a default was provided.
Raises
TypeError- If the concept cannot be determined and no default was given.
Examples
from relationalai.semantics import Model, String, inspect
m = Model("example")Person = m.Concept("Person")Person.name = m.Property(f"{Person} has {String:name}")inspect.to_concept(Person) is Person# Trueinspect.to_concept(Person.name, default=None) # returns Concept or None