Difference between str.isdigit() and str.isdecimal() in Python 3

Ian Kelly ian.g.kelly at gmail.com
Wed May 16 17:54:03 EDT 2012


On Wed, May 16, 2012 at 3:07 PM, Thomas 'PointedEars' Lahn
<PointedEars at web.de> wrote:
> RTFM.
>
> $ python3 -c 'print("42".isdecimal.__doc__ + "\n");
> print("42".isdigit.__doc__)'
> S.isdecimal() -> bool
>
> Return True if there are only decimal characters in S,
> False otherwise.
>
> S.isdigit() -> bool
>
> Return True if all characters in S are digits
> and there is at least one character in S, False otherwise.

Those doc strings are not very helpful at all.  I read them myself and
then had to go to the library docs to figure out what the actual
difference was.



More information about the Python-list mailing list