Python synergies in list addressingSomething I took from this Ian Bicking entry is that synergies and elegance don't just happen; someone usually worked hard to make it all come out neatly. Python lists have an interesting case of this; some apparently odd decisions in other places turn out to be needed to create useful (and error-avoiding) synergies. Python lists (and sequences in general) are indexed from 0. Zero-based
indexing presents a problem, which can be succinctly stated as this:
list element indexes run from 0 to So Python has quietly arranged things so that you never have to write it
(or
All of these are straightforward expressions, with nary a stray Python is not the first language to notice this issue; Scheme's
(This entry's genesis came from comments made on AClosureConfusion.) |
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |