Yet another list comprehension question

Posted by relima on Stack Overflow See other posts from Stack Overflow or by relima
Published on 2010-10-20T00:19:55Z Indexed on 2010/12/26 14:54 UTC
Read the original article Hit count: 185

Filed under:
|

I had this:

    if Setting["Language"] == "en":
        f.m_radioBox3.SetSelection(0)
    elif Setting["Language"] == "pt":
        f.m_radioBox3.SetSelection(1)
    elif Setting["Language"] == "fr":
        f.m_radioBox3.SetSelection(2)
    elif Setting["Language"] == "es":
        f.m_radioBox3.SetSelection(3)

Then I did this:

    Linguas = ["en","pt","fr","es"]
    a = 0
    for i in Linguas:
        if i == Setting["Language"]:
            f.m_radioBox3.SetSelection(a)
        a += 1

Is it possible to further simplify this and make it into a one-liner?

© Stack Overflow or respective owner

Related posts about python

Related posts about list-comprehension