[Python-ideas] Default return values to int and float

Nick Coghlan ncoghlan at gmail.com
Wed Oct 5 19:25:52 CEST 2011


On Oct 5, 2011 10:32 AM, "Ethan Furman" <ethan at stoneleaf.us> wrote:
>
> Ron Adam wrote:
>>
>> On Wed, 2011-10-05 at 19:08 +1300, Greg Ewing wrote:
>>>
>>> Guido van Rossum wrote:
>>>
>>>> I'm out of ideas here. But of all these, str.find is probably still
>>>> the worst -- I've flagged bugs caused by it too many times to count.
>>>
>>> Could a with-statement be used here somehow?
>>>
>>>     with finding(x, s) as i:
>>>         ...
>>
>>
>> Or an iterator.
>>
>>     for i in finding(x, s):
>>          ...
>
>
> How would the case of not found be handled in either of these proposals?

By never executing the body of the loop. It's still a thoroughly unnatural
API for the 0 or 1 case, though.

--
Nick Coghlan (via Gmail on Android, so likely to be more terse than usual)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111005/dd21ef10/attachment.html>


More information about the Python-ideas mailing list