We have string.isdigit(), why not string.isNumber()?

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Apr 30 22:25:01 EDT 2008


MooMaster <ntv1534 at gmail.com> writes:

> I know how to write a regexp or method or whatever to do this, my main
> question is *why* something like an isNumber() method is not baked
> into the class.

Because that name wouldn't conform to PEP 8.

(Also, and more importantly, because it's more correct to use it as
input to creating a new object of the type you want, and catch the
exception if it fails.)

-- 
 \       "Courage is resistance to fear, mastery of fear — not absence |
  `\                       of fear." —Mark Twain, _Pudd'n'head Wilson_ |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list