Author serhiy.storchaka
Recipients Austin Bingham, christian.heimes, facundobatista, mark.dickinson, rhettinger, robert_smallshire, serhiy.storchaka, skrah, tim.peters
Date 2018-03-12.22:26:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520893611.36.0.467229070634.issue26680@psf.upfronthosting.co.za>
In-reply-to
Content
As for StackOverflow links provided by Robert, it looks to me that float.is_integer() is always used improperly.

If keep this method it would be worth to warn against improper use of it.

Bad:

    (x/5).is_integer()

Good:

    x % 5 == 0

or

    not x % 5

Bad:

    math.sqrt(x).is_integer()

Good:

    int(math.sqrt(x))**2 == x

Bad:

    while x < y:
        if x.is_integer():
            print(x)
        x += 0.1

Good (if initial x was integer):

    x0 = x
    i = 0
    while x < y:
        x = x0 + i/10
        if not i % 10:
            print(x)
        i += 1

And provide an example of a *proper* use case (if it exists).
History
Date User Action Args
2018-03-12 22:26:51serhiy.storchakasetrecipients: + serhiy.storchaka, tim.peters, rhettinger, facundobatista, mark.dickinson, christian.heimes, skrah, robert_smallshire, Austin Bingham
2018-03-12 22:26:51serhiy.storchakasetmessageid: <1520893611.36.0.467229070634.issue26680@psf.upfronthosting.co.za>
2018-03-12 22:26:51serhiy.storchakalinkissue26680 messages
2018-03-12 22:26:51serhiy.storchakacreate