enumerate improvement proposal

Steve Holden steve at holdenweb.com
Mon Oct 30 18:42:16 EST 2006


James Stroud wrote:
> Diez B. Roggisch wrote:
> 
>>>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):
>>    if item.is_the_chosen_one():
>>        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.
>>
>>Diez
> 
> 
> Thank you for this explanation. Very illuminating. I think understand 
> this idea well and the thought of 1 basing this function makes me cringe 
> as much as the next guy (though I lacked the vocabulary to explain 
> exactly why I cringe).
> 
> But you see, weaning this university faculty level economist (who 
> already has her own way of doing everything...and to whom I happen to be 
> married) from the traditional economics tools of gauss and sas towards 
> the more sane and flexible tools of python, numarray, and rpy has been a 
> multi-stage process. Tweaking the chosen abstractions to not be as leaky 
> (thank you and thank Fredrik for introducing me to this vocabulary) is 
> still one of the things I'm working towards. I want to solidify the 
> conversion before I concentrate on nuance.
> 
> So, before too much criticism, I challenge even the most skilled python 
> programmer to find his or her own faculty economist (or statistician or 
> physicist) and get them to radically change their computational tools. 
> When you've walked a mile in my shoes, leaky abstractions won't seem 
> like such a big deal after all.
> 
Divorce is obviously the only answer. How could you end up marrying 
someone who counts from one and not zero? ;-)

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list