A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-March/152365.html below:

[Python-Dev] Symmetry arguments for API expansion

[Python-Dev] Symmetry arguments for API expansion [Python-Dev] Symmetry arguments for API expansionSerhiy Storchaka storchaka at gmail.com
Mon Mar 12 15:53:51 EDT 2018
12.03.18 21:15, Guido van Rossum пише:
> There's a reason why adding this to int feels right to me. In mypy we 
> treat int as a sub*type* of float, even though technically it isn't a 
> sub*class*.. The absence of an is_integer() method on int means that 
> this code has a bug that mypy doesn't catch:
> 
> def f(x: float):
>      if x.is_integer():
>          "do something"
>      else:
>          "do something else"

What is the real use case of float.is_integer()?

I searched on GitHub and found only misuses of it like 
(x/5).is_integer() (x % 5 == 0 would be more correct and clear) or 
(x**0.5).is_integer() (returns wrong result for large ints and some 
floats) in short examples. Some of these snippets look like book 
examples, and they propagate bad practices (like "if a.is_integer() == 
True:").

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4