Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_and_eval(element):
allowed_elements = circuit_elements.keys()
if element not in allowed_elements:
raise ValueError(f'{element} not in ' +
f'allowed elements ({allowed_elements})')
else:
return eval(element, circuit_elements)