[Python-3000] Droping find/rfind?
Paul Prescod
paul at prescod.net
Wed Aug 23 21:12:31 CEST 2006
Just throwing it out but what about something like:
found, index = text.index("abc")
if found:
doSomething(index)
If you were confident that the index was in there you would do something
more like this:
something = text[text.index("abc")[1]:]
(although there are clearer ways to do that)
On 8/23/06, Steven Bethard <steven.bethard at gmail.com> wrote:
>
> On 8/23/06, Barry Warsaw <barry at python.org> wrote:
> > I agree with Tim -- if we have to get rid of one of them, let's get
> > rid of index/rindex and keep find/rfind. Catching the exception is
> > much less convenient than testing for -1.
>
> Could you post a simple example or two? I keep imagining things like::
>
> index = text.index(...)
> if 0 <= index:
> ... do something with index ...
> else:
> ...
>
> which looks about the same as::
>
> try:
> index = text.index(...)
> ... do something with index ...
> except ValueError:
> ...
>
> Is it just that a lot of the else clauses are empty?
>
> STeVe
> --
> I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
> tiny blip on the distant coast of sanity.
> --- Bucky Katt, Get Fuzzy
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/paul%40prescod.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060823/71692915/attachment.html
More information about the Python-3000
mailing list