Why is the underscore in `float.is_integer`, but not in` str.isnumeric`?

It appears to float.is_integerbe the only "is" method with an underscore in its name among the built-in types in Python. Examples that do not include : Underline: str.isalnum, str.isalpha, str.isdecimal, str.isdigit, str.isidentifier, str.islower, str.isnumeric, str.isprintable, str.isspace, str.istitle, str.isupper.

Any clues as to why?

PEP 8 , I would expect all of these names to contain an underscore. But practicality is superior to cleanliness ( PEP 20 ), so omitting the underscore in commonly used and short names makes sense. However, both naming conventions immediately seem to be a consequence of backward compatibility (with a module loggingas a canonical example).

+4
source share
1 answer

A similar question was asked in the Python tracker signature:

isinstance, issubclass islower is_integer, is_fifo is_enabled. Python 3.6 , is, 69 . , . .

( . , Python):

, . Python , . - , .

, , is_integer - .

+2

Source: https://habr.com/ru/post/1684555/


All Articles