enumerate improvement proposal
Diez B. Roggisch
deets at nospam.web.de
Mon Oct 30 20:48:07 CET 2006
> Okay, I've googled "leaky abstractions" (as was probably your intended
> affect with your silence), read the famous essay, and still
> don't know what you mean and how it applies to what I have described.
> Do you plan to justify your statement or emptily accuse people of violating
> esoteric principles?
While I can't claim to know what the effbot thinks (the
skull-socks-wearing-python-coder-mindlink-technology is yet to be
developed), I think it's pretty clear what he is after here:
Computers compute offsets into data zero-based. Some languages like
pascal completely abstract that away from the user, but python doesn't.
So if your colleague/boss/whatever insists on indices being one-based,
this abstraction you introduced for her pretty fast leaks pretty badly.
Consider this simple example:
for offset, item in enumerate(some_list, start=1):
chosen_one_offset = offset
the_chosen_one = some_list[chosen_one_offset]
And bang, its Judas not Petrus who gets the pearly gates inc. stock options.
More information about the Python-list