homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author phammer
Recipients eric.araujo, phammer, r.david.murray, rhettinger, terry.reedy
Date 2011年05月25日.03:22:37
SpamBayes Score 2.489583e-07
Marked as misclassified No
Message-id <1306293758.78.0.861420661473.issue11889@psf.upfronthosting.co.za>
In-reply-to
Content
"""
Changing the 'enumerate' doc string text from:
| (0, seq[0]), (1, seq[1]), (2, seq[2]), ...
to:
| (start, seq[0]), (start+1, seq[1]), (start+2, seq[2]), ...
would completely disambiguate the doc string at the modest cost of
sixteen additional characters, a small price for pellucid clarity.
The proposed changes to the formal documentation also seem to me to
be prudent, and I hope at this late writing, they have already been
committed.
I conclude with a code fragment for the edification of R. David Murray.
"""
class numerate(object):
 """
 A demonstration of a plausible incorrect interpretation of
 the 'enumerate' function's doc string and documentation.
 """
 def __init__(self,seq,start=0):
 self.seq=seq; self.index=start-1
 try:
 if seq.next: pass #test for iterable
 for i in xrange(start): self.seq.next()
 except:
 if type(seq)==dict: self.seq=seq.keys()
 self.seq=iter(self.seq[start:])
 def next(self):
 self.index+=1
 return self.index,self.seq.next()
 
 def __iter__(self): return self
if __name__ == "__main__":
 #s=['spring','summer','autumn','winter']
 s={'spring':'a','summer':'b','autumn':'c','winter':'d'}
 #s=enumerate(s)#,2)
 s=numerate(s,2)
 for t in s: print t
History
Date User Action Args
2011年05月25日 03:22:38phammersetrecipients: + phammer, rhettinger, terry.reedy, eric.araujo, r.david.murray
2011年05月25日 03:22:38phammersetmessageid: <1306293758.78.0.861420661473.issue11889@psf.upfronthosting.co.za>
2011年05月25日 03:22:38phammerlinkissue11889 messages
2011年05月25日 03:22:37phammercreate

AltStyle によって変換されたページ (->オリジナル) /