Difference between str.isdigit() and str.isdecimal() in Python 3
Devin Jeanpierre
jeanpierreda at gmail.com
Thu May 17 04:23:50 EDT 2012
On Wed, May 16, 2012 at 5:07 PM, Thomas 'PointedEars' Lahn
<PointedEars at web.de> wrote:
> RTFM.
>
> $ python3 -c 'print("42".isdecimal.__doc__ + "\n");
> print("42".isdigit.__doc__)'
Heh, don't print docstrings. Use pydoc.
$ ( export PAGER=cat && pydoc3 str.isdecimal && pydoc3 str.isdigit )
Help on method_descriptor in str:
str.isdecimal = isdecimal(...)
S.isdecimal() -> bool
Return True if there are only decimal characters in S,
False otherwise.
Help on method_descriptor in str:
str.isdigit = isdigit(...)
S.isdigit() -> bool
Return True if all characters in S are digits
and there is at least one character in S, False otherwise.
---
Although pydoc is still really bad compared to the web/reST
documentation. (This has been noted by others.)
---
By the way, is it worth filing a bug report on the wording of
str.isdecimal()? It seems to imply that ''.isdecimal() should be true.
(It isn't.) Especially when compared like that to isdigit, which makes
a point of noting this particular edge case.
-- Devin
More information about the Python-list
mailing list