[Python-ideas] Default return values to int and float
Ethan Furman
ethan at stoneleaf.us
Wed Oct 5 20:07:40 CEST 2011
Ron Adam wrote:
> On Wed, 2011-10-05 at 07:31 -0700, Ethan Furman wrote:
>> for i in finding(x, s):
>> ...
>> else:
>> # unless for loop has a break, this will happen...
>> # not a problem until you want more than just the first
>> # occurrence of s in x
>
>
> for i in finding(x, s):
> if i > 25:
> break
> <build or get a result>
> else:
> return result
> raise(ValueError("string 's' had an 'x' after position 25")
And how did you decide on the magical number 25?
~Ethan~
More information about the Python-ideas
mailing list