4 ms·
I agree, but people frequently submit with [0] so wanted to ask. Here’s an example from today: https://news.ycombinator.com/item?id=22316070 https://news.ycomb
by sbr464 7y ago
I agree, but people frequently submit with [0] so wanted to ask. Here’s an example from today:
https://news.ycombinator.com/item?id=22316070 https://news.ycombinator.com/item?id=22316070
- archi42 7y agoI suppose the average HN commentator is used to indexing arrays using the postfix []-operator, thus starting at 0, while the tools mentioned by GP are aimed at everyone - and most "normal" people start counting at 1. For references in manually written text, it doesn't matter at all - as opposed to programming language design. E.g. in C the equality x[a] == <star>(x + a) holds because we start at 0. OTOH if we started at 1, it would become x[a] == <star>(x + a - 1). Mathematically it does not really matter as well, but if you're doing lots of pointer arithmetics in C, causing massive bugs by forgetting a crucial " - 1" might be all too easy. No idea if this was inherited from predecessors or an original design decision. Might also be just a coincidence and the reason to start at [0] is an entirely different one ;-) (sorry for the <star>, I mean * -- but using multiple of these is interpreted as formatting/italics and I don't know how to avoid this)
- brudgers 7y agoIt doesn't matter. HN has no PEP8.