Simple question of python: String to a defined value

I have these values:
unicode = ‘X’
unicode = ‘Y’
or
unicode = ‘Z’

So I can to define a vector for each value of unicode:
def value (unicode):
… if unicode == ‘X’:
… return (1,0,0)
… elif unicode == ‘Y’:
… return (0,1,0)
… elif unicode == ‘Z’:
… return (0,0,1)

But does it have a simpler way to do this? Preferably on one line?[SUB](If the answer is no I can understand.)

[/SUB]

Yes, a dictionary:

value_mapping = {
    "X": (1, 0, 0),
    "Y": (0, 1, 0),
    "Z": (0, 0, 1),
}

unicode = "X"
value = value_mapping[unicode]

Or a really funky version:

[1 if ord(unicode.upper()) - 88 == i else 0 for i in range(3)]

Wool! The funky version is interesting :eek:. But I will use the dictionary. :slight_smile:
Thank you again @CoDEmanX