This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients belopolsky, pitrou, rhettinger
Date 2008-05-30.14:52:28
SpamBayes Score 0.023528714
Marked as misclassified No
Message-id <1212159161.32.0.36323637599.issue3008@psf.upfronthosting.co.za>
In-reply-to
Content
Well it's quite simple. Imagine you have a function f() which takes an
integer parameter named x, and somewhere applies bin() to this parameters.

Right now, if you call f(1.0) instead of f(1), you will get a TypeError,
which is easy to detect: you then fix the call to f(1), and bin()
produces the expected result ('0b1').

With Raymond's suggestion, if you call f(1.0) instead of f(1), no
exception will tell you your mistake, and bin() will produce a
completely bogus result compared to the expected one. If you notice the
bogus function output and find out that it contains a strange-looking
string (something like
'0b11.001001000011111101101010100010001000010110100011'), it is still
not obvious from it that the problem stems from passing a float instead
of an int. Especially if f() is a library function which you didn't
write yourself.

There is a reason Python recently introduced a stronger distinction
between ints and floats (for instance the __index__ method, which bin()
seems to use currently), I don't see the logic behind trying to undo it.

And it's not like printing the bin() representation of a float has any
actually use (besides education, but education can use its own tools
rather than builtin functions).
History
Date User Action Args
2008-05-30 14:52:41pitrousetspambayes_score: 0.0235287 -> 0.023528714
recipients: + pitrou, rhettinger, belopolsky
2008-05-30 14:52:41pitrousetspambayes_score: 0.0235287 -> 0.0235287
messageid: <1212159161.32.0.36323637599.issue3008@psf.upfronthosting.co.za>
2008-05-30 14:52:34pitroulinkissue3008 messages
2008-05-30 14:52:32pitroucreate