A bug I found in Python

Nicodemus nicodemus at globalite.com.br
Sat Mar 29 21:09:31 EST 2003


Bwahuahuahaua. Priceless.

Tim Peters wrote:

>[Jp Calderone]
>  
>
>>  I have used Python for many minutes now, but I have recently discovered
>>    
>>
>some surprising behavior!
>
>I salute you for lasting so long.  Most people give up on Python after a few
>seconds.  We appreciate that you took valuable time to inform us of the
>language's flaws.  You should stop now, though, lest it consume your life.
>
>  
>
>>  When I attempt to add two integers together, the result is a third,
>>different integer!
>>    
>>
>
>Math isn't Guido's stong suit, despite his degrees in the topic.  It might
>help to think of Python as doing Dutch Math, where it's often the case that
>integers *nobody* has ever seen before pop up out of nowhere, for no reason
>at all.  This happens a lot.
>
>  
>
>>  Here is an example of this surprising behavior:
>>
>>      def biffle_buffle_bam(x, y):
>>          z = 10
>>          print 'Hello world'
>>          return anotherFunctionIWrote(x, y)
>>
>>      print biffle_bam_baffle(10, -10)
>>
>>  As you can clearly see, when this is run, 0 is printed out!
>>I think this is very surprising behavior, since I did not type 0
>>into my program at all, only 10 and -10.
>>    
>>
>
>Yes, it's clearly a bug in Python.  What's happening is that it saw the 0 in
>"10", and the zero in "-10", and figured 0 was the most popular digit.   As
>is so often the case, Python sacrificed accuracy for popularity.
>
>  
>
>>  Maybe this is documented somewhere, but I am too busy adding integers
>>together by hand to look up the answer.  Maybe if Python were less
>>surprising I would not have to do this!
>>    
>>
>
>You're absolutely right, and I apologize for the needless pain you've
>suffered.
>
>  
>
>>  Can anyone explain why this design flaw was placed into Python?
>>    
>>
>
>Just a combination of Guido trying to be popular, and, frankly, stupidity.
>For the same reason, in
>
>  
>
>>>>.1
>>>>        
>>>>
>0.10000000000000001
>  
>
>
>Guido tries to be so popular by printing lots of zeroes that he forgets he
>already printed the 1, so prints it again.  It's outrageous.
>
>
>  
>







More information about the Python-list mailing list