[Tutor] unicode: alpha, whitespaces and digits

eryksun eryksun at gmail.com
Mon Dec 30 00:44:22 CET 2013


On Sun, Dec 29, 2013 at 5:58 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> If you want to test for something that a human reader will recognise as
> a "whole number", s.isdigit() is probably the best one to use.

isdigit() includes decimal digits plus other characters that have a digit value:

    >>> print u'\N{superscript two}'
    ²
    >>> unicodedata.digit(u'\N{superscript two}')
    2

However, int(u'\N{superscript two}') raises a ValueError. int() only
accepts the subset of digits that are isdecimal().


More information about the Tutor mailing list