A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-August/027392.html below:

[Python-Dev] string.find() again (was Re: timsort for jython)

[Python-Dev] string.find() again (was Re: timsort for jython) [Python-Dev] string.find() again (was Re: timsort for jython)Tim Peters tim.one@comcast.net
Mon, 05 Aug 2002 16:15:41 -0400
[Tim]
> I'd like to see a plausible use case for
>
>     '' in str
>
> returning True, then.

[Gordon McMillan]
> Any code that currently does
>  str.find(x) >= 0

You're saying that you actually do that in cases where x may be an empty
string, and that it's useful to get a True result in at least one such case?
If you are saying that, it needs more details; but if you're not saying
that, it's not a relevant use case.

> I tend to use:
>
>  pos = str.find(x)
>  if pos > -1:
>
> because I'm normally interested in where.

Sure -- that's what .find() is for, after all.  But you're also saying that
your algorithms expect to search for empty strings?  Like in:

    index = option_letter_string.find(letter)
    if index >= 0:
        list_of_option_functions[index]()
    else:
        raise UnknownOptionLetter(letter)

you make sure that list_of_option_functions[0] is suitable for processing
both the first option in option_letter_string and an empty "option letter"?




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4