A Bug By Any Other Name ...

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Jul 6 03:49:28 EDT 2009

En Mon, 06 Jul 2009 03:33:36 -0300, Gary Herron  
<gherron at islandtraining.com> escribió:
> Gabriel Genellina wrote:
>> En Mon, 06 Jul 2009 00:28:43 -0300, Steven D'Aprano  
>> <steve at remove-this-cybersource.com.au> escribió:
>>> On Mon, 06 Jul 2009 14:32:46 +1200, Lawrence D'Oliveiro wrote:
>>>> I wonder how many people have been tripped up by the fact that
>>>>     ++n
>>>> and
>>>>     --n
>>>> fail silently for numeric-valued n.
>>> What do you mean, "fail silently"? They do exactly what you should  
>>> expect:
>>>>>> ++5  # positive of a positive number is positive
>>> I'm not sure what "bug" you're seeing. Perhaps it's your expectations
>>> that are buggy, not Python.
>> Well, those expectations are taken seriously when new features are  
>> introduced into the language - and sometimes the feature is dismissed  
>> just because it would be confusing for some.
>> If a += 1 works, expecting ++a to have the same meaning is very  
>> reasonable (for those coming from languages with a ++ operator, like C  
>> or Java) - more when ++a is a perfectly valid expression.
>> If this issue isn't listed under the various "Python gotchas" articles,  
>> it should...
> Well sure, it's not unreasonable to expect ++n and --n to behave as in  
> other languages, and since they don't, perhaps they should be listed as  
> a "Python gotcha". But even so, it's quite arrogant of the OP to flaunt  
> his ignorance of the language by claiming this is a bug and a failure.   
> It shouldn't have been all that hard for him to figure out what was  
> really happening.

That depends on what you call a "bug". In his classical book "The art of  
software testing", Myers says that a program has a bug when it doesn't  
perform as the user expects reasonably it to do (not an exact quote, I  
don't have the book at hand). That's a lot broader than developers like to  

In this case, a note in the documentation warning about the potential  
confusion would be fine.

Gabriel Genellina

More information about the Python-list mailing list