Movatterモバイル変換
[0]ホーム
[Python-Dev] partition()
Raymond Hettingerraymond.hettinger at verizon.net
Tue Aug 30 17:11:53 CEST 2005
Hey guys, don't get lost in random naming suggestions (cut, snap, part,parts, yada yada yada). Each of those is much less descriptive andprovides less differentiation from other string methods. Saving a fewcharacters is not worth introducing ambiguity.Also, the longer name provides a useful visual balance between the threeassigned variables and the separator argument. As an extreme example,contrast the following: head, found, tail = s.p(separator) head, found, tail = s.partition(separator)The verb gets lost if it doesn't have visual weight.Also, for those suggesting alternate semantics (raising exceptions whenthe separator is not found), I challenge you to prove their worth bydoing all the code transformations that I did. It is a remarkablyinformative exercise that quickly reveals that this alternative isdead-on-arrival.For the poster suggesting an optional length argument, I suggest writingout the revised method invariants. I think you'll find that it snarlsthem into incomprehensibility and makes the tool much more difficult tolearn. Also, I recommend scanning my sample library codetransformations to see if any of them would benefit from the lengthargument. I think you'll find that it comes up so infrequently and withsuch differing needs that it would be a mistake to bake this into theproposal.Raymond
More information about the Python-Devmailing list
[8]ページ先頭