Multi-dimensional list initialization

Chris Angelico rosuav at gmail.com
Fri Nov 9 07:07:09 CET 2012


On Fri, Nov 9, 2012 at 12:39 PM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
> On 07/11/2012 01:55, Steven D'Aprano wrote:
>>
>>
>> Who knows? Who cares? Nobody does:
>>
>> n -= n
>>
>
> But I've seen this scattered through code:
>
> x := x - x - x

Can you enlighten us as to how this is better than either:
 x := -x
or
 x := 0 - x
? I'm not seeing it. And I'm not seeing any nonnumeric that would
benefit from being subtracted from itself twice (strings, arrays,
sets, you can subtract them from one another but not usefully more
than once).

ChrisA


More information about the Python-list mailing list