[Python-3000] find -> index patch

Fredrik Lundh fredrik at pythonware.com
Thu Aug 24 15:48:57 CEST 2006


Michael Chermside wrote:

>> WOW, I love partition.  In all the instances that weren't a simple "in"
>> test I ended up using [r]partition.  In some cases one of the returned
>> strings gets thrown away but in those cases it is guaranteed to be small.
>> The new code is usually smaller than the old and generally clearer.
>
> Wow. That's just beautiful. This has now convinced me that dumping
> [r]find() (at least!) and pushing people toward using partition will
> result in pain in the short term (of course), and beautiful, readable
> code in the long term.

note that partition provides an elegant solution to an important *subset* of all
problems addressed by find/index.

just like lexical scoping vs. default arguments and map vs. list comprehensions,
it doesn't address all problems right out of the box, and shouldn't be advertised
as doing that.

</F> 





More information about the Python-3000 mailing list