More Than Just ASCII Digits

Python’s int() converts more than just ASCII digits. It also converts decimal digits from other scripts.

>>> int('42')
42
>>> int(u'୨୩')
23

It’s also possible to mix differnt scripts. int() only cares about the decimal value of each digit character.

>>> int(u'௧౩౩೭')
1337

The following snippet creates CSV data for all digits int() can convert:

#!/usr/bin/env python
# coding: utf8
from __future__ import absolute_import, division, print_function
import sys
import unicodedata


def main():
    for i in xrange(sys.maxunicode + 1):
        try:
            character = unichr(i)
            value = int(character)
        except ValueError:
            pass
        else:
            print(
                u'{0},{1},{2:x},{3}'.format(
                    character, value, i, unicodedata.name(character).lower()
                ).encode('utf8')
            )


if __name__ == '__main__':
    main()

And here’s the table generated by that script:

All digits Python 2.7’s int() converts.
Character Value Codepoint (hex) Name
0 0 30 digit zero
1 1 31 digit one
2 2 32 digit two
3 3 33 digit three
4 4 34 digit four
5 5 35 digit five
6 6 36 digit six
7 7 37 digit seven
8 8 38 digit eight
9 9 39 digit nine
٠ 0 660 arabic-indic digit zero
١ 1 661 arabic-indic digit one
٢ 2 662 arabic-indic digit two
٣ 3 663 arabic-indic digit three
٤ 4 664 arabic-indic digit four
٥ 5 665 arabic-indic digit five
٦ 6 666 arabic-indic digit six
٧ 7 667 arabic-indic digit seven
٨ 8 668 arabic-indic digit eight
٩ 9 669 arabic-indic digit nine
۰ 0 6f0 extended arabic-indic digit zero
۱ 1 6f1 extended arabic-indic digit one
۲ 2 6f2 extended arabic-indic digit two
۳ 3 6f3 extended arabic-indic digit three
۴ 4 6f4 extended arabic-indic digit four
۵ 5 6f5 extended arabic-indic digit five
۶ 6 6f6 extended arabic-indic digit six
۷ 7 6f7 extended arabic-indic digit seven
۸ 8 6f8 extended arabic-indic digit eight
۹ 9 6f9 extended arabic-indic digit nine
߀ 0 7c0 nko digit zero
߁ 1 7c1 nko digit one
߂ 2 7c2 nko digit two
߃ 3 7c3 nko digit three
߄ 4 7c4 nko digit four
߅ 5 7c5 nko digit five
߆ 6 7c6 nko digit six
߇ 7 7c7 nko digit seven
߈ 8 7c8 nko digit eight
߉ 9 7c9 nko digit nine
0 966 devanagari digit zero
1 967 devanagari digit one
2 968 devanagari digit two
3 969 devanagari digit three
4 96a devanagari digit four
5 96b devanagari digit five
6 96c devanagari digit six
7 96d devanagari digit seven
8 96e devanagari digit eight
9 96f devanagari digit nine
0 9e6 bengali digit zero
1 9e7 bengali digit one
2 9e8 bengali digit two
3 9e9 bengali digit three
4 9ea bengali digit four
5 9eb bengali digit five
6 9ec bengali digit six
7 9ed bengali digit seven
8 9ee bengali digit eight
9 9ef bengali digit nine
0 a66 gurmukhi digit zero
1 a67 gurmukhi digit one
2 a68 gurmukhi digit two
3 a69 gurmukhi digit three
4 a6a gurmukhi digit four
5 a6b gurmukhi digit five
6 a6c gurmukhi digit six
7 a6d gurmukhi digit seven
8 a6e gurmukhi digit eight
9 a6f gurmukhi digit nine
0 ae6 gujarati digit zero
1 ae7 gujarati digit one
2 ae8 gujarati digit two
3 ae9 gujarati digit three
4 aea gujarati digit four
5 aeb gujarati digit five
6 aec gujarati digit six
7 aed gujarati digit seven
8 aee gujarati digit eight
9 aef gujarati digit nine
0 b66 oriya digit zero
1 b67 oriya digit one
2 b68 oriya digit two
3 b69 oriya digit three
4 b6a oriya digit four
5 b6b oriya digit five
6 b6c oriya digit six
7 b6d oriya digit seven
8 b6e oriya digit eight
9 b6f oriya digit nine
0 be6 tamil digit zero
1 be7 tamil digit one
2 be8 tamil digit two
3 be9 tamil digit three
4 bea tamil digit four
5 beb tamil digit five
6 bec tamil digit six
7 bed tamil digit seven
8 bee tamil digit eight
9 bef tamil digit nine
0 c66 telugu digit zero
1 c67 telugu digit one
2 c68 telugu digit two
3 c69 telugu digit three
4 c6a telugu digit four
5 c6b telugu digit five
6 c6c telugu digit six
7 c6d telugu digit seven
8 c6e telugu digit eight
9 c6f telugu digit nine
0 ce6 kannada digit zero
1 ce7 kannada digit one
2 ce8 kannada digit two
3 ce9 kannada digit three
4 cea kannada digit four
5 ceb kannada digit five
6 cec kannada digit six
7 ced kannada digit seven
8 cee kannada digit eight
9 cef kannada digit nine
0 d66 malayalam digit zero
1 d67 malayalam digit one
2 d68 malayalam digit two
3 d69 malayalam digit three
4 d6a malayalam digit four
5 d6b malayalam digit five
6 d6c malayalam digit six
7 d6d malayalam digit seven
8 d6e malayalam digit eight
9 d6f malayalam digit nine
0 e50 thai digit zero
1 e51 thai digit one
2 e52 thai digit two
3 e53 thai digit three
4 e54 thai digit four
5 e55 thai digit five
6 e56 thai digit six
7 e57 thai digit seven
8 e58 thai digit eight
9 e59 thai digit nine
0 ed0 lao digit zero
1 ed1 lao digit one
2 ed2 lao digit two
3 ed3 lao digit three
4 ed4 lao digit four
5 ed5 lao digit five
6 ed6 lao digit six
7 ed7 lao digit seven
8 ed8 lao digit eight
9 ed9 lao digit nine
0 f20 tibetan digit zero
1 f21 tibetan digit one
2 f22 tibetan digit two
3 f23 tibetan digit three
4 f24 tibetan digit four
5 f25 tibetan digit five
6 f26 tibetan digit six
7 f27 tibetan digit seven
8 f28 tibetan digit eight
9 f29 tibetan digit nine
0 1040 myanmar digit zero
1 1041 myanmar digit one
2 1042 myanmar digit two
3 1043 myanmar digit three
4 1044 myanmar digit four
5 1045 myanmar digit five
6 1046 myanmar digit six
7 1047 myanmar digit seven
8 1048 myanmar digit eight
9 1049 myanmar digit nine
0 1090 myanmar shan digit zero
1 1091 myanmar shan digit one
2 1092 myanmar shan digit two
3 1093 myanmar shan digit three
4 1094 myanmar shan digit four
5 1095 myanmar shan digit five
6 1096 myanmar shan digit six
7 1097 myanmar shan digit seven
8 1098 myanmar shan digit eight
9 1099 myanmar shan digit nine
0 17e0 khmer digit zero
1 17e1 khmer digit one
2 17e2 khmer digit two
3 17e3 khmer digit three
4 17e4 khmer digit four
5 17e5 khmer digit five
6 17e6 khmer digit six
7 17e7 khmer digit seven
8 17e8 khmer digit eight
9 17e9 khmer digit nine
0 1810 mongolian digit zero
1 1811 mongolian digit one
2 1812 mongolian digit two
3 1813 mongolian digit three
4 1814 mongolian digit four
5 1815 mongolian digit five
6 1816 mongolian digit six
7 1817 mongolian digit seven
8 1818 mongolian digit eight
9 1819 mongolian digit nine
0 1946 limbu digit zero
1 1947 limbu digit one
2 1948 limbu digit two
3 1949 limbu digit three
4 194a limbu digit four
5 194b limbu digit five
6 194c limbu digit six
7 194d limbu digit seven
8 194e limbu digit eight
9 194f limbu digit nine
0 19d0 new tai lue digit zero
1 19d1 new tai lue digit one
2 19d2 new tai lue digit two
3 19d3 new tai lue digit three
4 19d4 new tai lue digit four
5 19d5 new tai lue digit five
6 19d6 new tai lue digit six
7 19d7 new tai lue digit seven
8 19d8 new tai lue digit eight
9 19d9 new tai lue digit nine
1 19da new tai lue tham digit one
0 1a80 tai tham hora digit zero
1 1a81 tai tham hora digit one
2 1a82 tai tham hora digit two
3 1a83 tai tham hora digit three
4 1a84 tai tham hora digit four
5 1a85 tai tham hora digit five
6 1a86 tai tham hora digit six
7 1a87 tai tham hora digit seven
8 1a88 tai tham hora digit eight
9 1a89 tai tham hora digit nine
0 1a90 tai tham tham digit zero
1 1a91 tai tham tham digit one
2 1a92 tai tham tham digit two
3 1a93 tai tham tham digit three
4 1a94 tai tham tham digit four
5 1a95 tai tham tham digit five
6 1a96 tai tham tham digit six
7 1a97 tai tham tham digit seven
8 1a98 tai tham tham digit eight
9 1a99 tai tham tham digit nine
0 1b50 balinese digit zero
1 1b51 balinese digit one
2 1b52 balinese digit two
3 1b53 balinese digit three
4 1b54 balinese digit four
5 1b55 balinese digit five
6 1b56 balinese digit six
7 1b57 balinese digit seven
8 1b58 balinese digit eight
9 1b59 balinese digit nine
0 1bb0 sundanese digit zero
1 1bb1 sundanese digit one
2 1bb2 sundanese digit two
3 1bb3 sundanese digit three
4 1bb4 sundanese digit four
5 1bb5 sundanese digit five
6 1bb6 sundanese digit six
7 1bb7 sundanese digit seven
8 1bb8 sundanese digit eight
9 1bb9 sundanese digit nine
0 1c40 lepcha digit zero
1 1c41 lepcha digit one
2 1c42 lepcha digit two
3 1c43 lepcha digit three
4 1c44 lepcha digit four
5 1c45 lepcha digit five
6 1c46 lepcha digit six
7 1c47 lepcha digit seven
8 1c48 lepcha digit eight
9 1c49 lepcha digit nine
0 1c50 ol chiki digit zero
1 1c51 ol chiki digit one
2 1c52 ol chiki digit two
3 1c53 ol chiki digit three
4 1c54 ol chiki digit four
5 1c55 ol chiki digit five
6 1c56 ol chiki digit six
7 1c57 ol chiki digit seven
8 1c58 ol chiki digit eight
9 1c59 ol chiki digit nine
0 a620 vai digit zero
1 a621 vai digit one
2 a622 vai digit two
3 a623 vai digit three
4 a624 vai digit four
5 a625 vai digit five
6 a626 vai digit six
7 a627 vai digit seven
8 a628 vai digit eight
9 a629 vai digit nine
0 a8d0 saurashtra digit zero
1 a8d1 saurashtra digit one
2 a8d2 saurashtra digit two
3 a8d3 saurashtra digit three
4 a8d4 saurashtra digit four
5 a8d5 saurashtra digit five
6 a8d6 saurashtra digit six
7 a8d7 saurashtra digit seven
8 a8d8 saurashtra digit eight
9 a8d9 saurashtra digit nine
0 a900 kayah li digit zero
1 a901 kayah li digit one
2 a902 kayah li digit two
3 a903 kayah li digit three
4 a904 kayah li digit four
5 a905 kayah li digit five
6 a906 kayah li digit six
7 a907 kayah li digit seven
8 a908 kayah li digit eight
9 a909 kayah li digit nine
0 a9d0 javanese digit zero
1 a9d1 javanese digit one
2 a9d2 javanese digit two
3 a9d3 javanese digit three
4 a9d4 javanese digit four
5 a9d5 javanese digit five
6 a9d6 javanese digit six
7 a9d7 javanese digit seven
8 a9d8 javanese digit eight
9 a9d9 javanese digit nine
0 aa50 cham digit zero
1 aa51 cham digit one
2 aa52 cham digit two
3 aa53 cham digit three
4 aa54 cham digit four
5 aa55 cham digit five
6 aa56 cham digit six
7 aa57 cham digit seven
8 aa58 cham digit eight
9 aa59 cham digit nine
0 abf0 meetei mayek digit zero
1 abf1 meetei mayek digit one
2 abf2 meetei mayek digit two
3 abf3 meetei mayek digit three
4 abf4 meetei mayek digit four
5 abf5 meetei mayek digit five
6 abf6 meetei mayek digit six
7 abf7 meetei mayek digit seven
8 abf8 meetei mayek digit eight
9 abf9 meetei mayek digit nine
0 ff10 fullwidth digit zero
1 ff11 fullwidth digit one
2 ff12 fullwidth digit two
3 ff13 fullwidth digit three
4 ff14 fullwidth digit four
5 ff15 fullwidth digit five
6 ff16 fullwidth digit six
7 ff17 fullwidth digit seven
8 ff18 fullwidth digit eight
9 ff19 fullwidth digit nine
𐒠 0 104a0 osmanya digit zero
𐒡 1 104a1 osmanya digit one
𐒢 2 104a2 osmanya digit two
𐒣 3 104a3 osmanya digit three
𐒤 4 104a4 osmanya digit four
𐒥 5 104a5 osmanya digit five
𐒦 6 104a6 osmanya digit six
𐒧 7 104a7 osmanya digit seven
𐒨 8 104a8 osmanya digit eight
𐒩 9 104a9 osmanya digit nine
𝟎 0 1d7ce mathematical bold digit zero
𝟏 1 1d7cf mathematical bold digit one
𝟐 2 1d7d0 mathematical bold digit two
𝟑 3 1d7d1 mathematical bold digit three
𝟒 4 1d7d2 mathematical bold digit four
𝟓 5 1d7d3 mathematical bold digit five
𝟔 6 1d7d4 mathematical bold digit six
𝟕 7 1d7d5 mathematical bold digit seven
𝟖 8 1d7d6 mathematical bold digit eight
𝟗 9 1d7d7 mathematical bold digit nine
𝟘 0 1d7d8 mathematical double-struck digit zero
𝟙 1 1d7d9 mathematical double-struck digit one
𝟚 2 1d7da mathematical double-struck digit two
𝟛 3 1d7db mathematical double-struck digit three
𝟜 4 1d7dc mathematical double-struck digit four
𝟝 5 1d7dd mathematical double-struck digit five
𝟞 6 1d7de mathematical double-struck digit six
𝟟 7 1d7df mathematical double-struck digit seven
𝟠 8 1d7e0 mathematical double-struck digit eight
𝟡 9 1d7e1 mathematical double-struck digit nine
𝟢 0 1d7e2 mathematical sans-serif digit zero
𝟣 1 1d7e3 mathematical sans-serif digit one
𝟤 2 1d7e4 mathematical sans-serif digit two
𝟥 3 1d7e5 mathematical sans-serif digit three
𝟦 4 1d7e6 mathematical sans-serif digit four
𝟧 5 1d7e7 mathematical sans-serif digit five
𝟨 6 1d7e8 mathematical sans-serif digit six
𝟩 7 1d7e9 mathematical sans-serif digit seven
𝟪 8 1d7ea mathematical sans-serif digit eight
𝟫 9 1d7eb mathematical sans-serif digit nine
𝟬 0 1d7ec mathematical sans-serif bold digit zero
𝟭 1 1d7ed mathematical sans-serif bold digit one
𝟮 2 1d7ee mathematical sans-serif bold digit two
𝟯 3 1d7ef mathematical sans-serif bold digit three
𝟰 4 1d7f0 mathematical sans-serif bold digit four
𝟱 5 1d7f1 mathematical sans-serif bold digit five
𝟲 6 1d7f2 mathematical sans-serif bold digit six
𝟳 7 1d7f3 mathematical sans-serif bold digit seven
𝟴 8 1d7f4 mathematical sans-serif bold digit eight
𝟵 9 1d7f5 mathematical sans-serif bold digit nine
𝟶 0 1d7f6 mathematical monospace digit zero
𝟷 1 1d7f7 mathematical monospace digit one
𝟸 2 1d7f8 mathematical monospace digit two
𝟹 3 1d7f9 mathematical monospace digit three
𝟺 4 1d7fa mathematical monospace digit four
𝟻 5 1d7fb mathematical monospace digit five
𝟼 6 1d7fc mathematical monospace digit six
𝟽 7 1d7fd mathematical monospace digit seven
𝟾 8 1d7fe mathematical monospace digit eight
𝟿 9 1d7ff mathematical monospace digit nine