str(as.roman("VII"))
## Class 'roman'  int 7
X <- 10
r <- "XVI"
get(substr(r,1,1))
## [1] 10

I asked StackOverflow how to do this in Python. The answer:

X = 10
r = "XVI"
print(locals()[r[0]])
## 10

This question is an example of the use-mention distinction, which is played with in Lewis Carroll’s Through the Looking Glass; are we interested in the value of the symbol X, or the value of the symbol named "X"?

PPS: This feels like an example of Gelman’s God is in every leaf of every tree