Nick Coghlan wrote:

A couple of errors in the sample code.

> The new method would have semantics like:
> 
>    def partition_indices(self, sep, limits=None):
>        if limits is None:
>            limits = range(0, len(self))
>        else:
>            limits = limits.indices(len(self))

Either that line should be:
            limits = range(*limits.indices(len(self)))

Or the definition of indices() would need to be changed to return a range() 
object instead of a 3-tuple.

> For comparison, here's the normal copying version that has problems scaling 
> to 
> large strings:
> 
> def splitpartition(s):
>       rest = s
>       while 1:
>           prefix, lbrace, rest = rest.partition_indices("{")
>           first, space, rest = rest.partition_indices(" ")
>           second, rbrace, rest = rest.partition_indices("}")

Those 3 lines should be:
           prefix, lbrace, rest = rest.partition("{")
           first, space, rest = rest.partition(" ")
           second, rbrace, rest = rest.partition("}")

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to