=- and -= snag
MRAB
python at mrabarnett.plus.com
Mon Mar 13 21:05:55 EDT 2023
On 2023-03-14 00:28, Gary Herron wrote:
>
> On 3/13/23 2:26 PM, morphex at gmail.com wrote:
>> Hi.
>>
>> I was working in Python today, and sat there scratching my head as the
>> numbers for calculations didn't add up. It went into negative numbers,
>> when that shouldn't have been possible.
>>
>> Turns out I had a very small typo, I had =- instead of -=.
>>
>> Isn't it unpythonic to be able to make a mistake like that?
>>
>> Regards,
>>
>> Morten
>>
>
> These all mean the same thing, but I don't see a good way to designate
> the second or third as an error.
>
>
> x = -5
> x=-5
> x =- 5
>
The third one could be picked up as suspicious by a linter due to its
unusual spacing.
More information about the Python-list
mailing list