A Bug By Any Other Name ...
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Jul 5 23:28:43 EDT 2009
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
5
>>> --5 # negative of a negative number is positive
5
>>> -+5 # negative of a positive number is negative
-5
So does the bitwise-not unary operator:
>>> ~~5
5
I'm not sure what "bug" you're seeing. Perhaps it's your expectations
that are buggy, not Python.
--
Steven
More information about the Python-list
mailing list