def string_to_number(s, alphabet):
base = len(alphabet)<EOL>inverse_alphabet = dict(zip(alphabet, xrange(<NUM_LIT:0>, base)))<EOL>n = <NUM_LIT:0><EOL>exp = <NUM_LIT:0><EOL>for i in reversed(s):<EOL><INDENT>n += inverse_alphabet[i] * (base ** exp)<EOL>exp += <NUM_LIT:1><EOL><DEDENT>return n<EOL>
Given a string ``s``, convert it to an integer composed of the given
``alphabet`` mapping, where the position of each element in ``alphabet`` is
its radix value.

Examples::

    >>> string_to_number('101111000110000101001110', '01')
    12345678

    >>> string_to_number('babbbbaaabbaaaababaabbba', 'ab')
    12345678

    >>> string_to_number('ZXP0', string.ascii_letters + string.digits)
    12345678