[Python-ideas] Where-statement (Proposal for function expressions)
Jim Jewett
jimjjewett at gmail.com
Fri Jul 17 03:05:10 CEST 2009
On Thu, Jul 16, 2009 at 8:04 PM, Jan Kaliszewski<zuo at chopin.edu.pl> wrote:
> ... I don't see any reasonable *semantics* of
> return or yield within where-block in proposed form.
next_batch = myfilter(candidates, failed) where:
failed=[]
for x in this_batch:
if magical(x):
# We actually found one!!!
return x
# more failures, of course.
# bias the next batch to a different section
# of the search space.
failed.append(x)
I leave to others the judgment on whether or not any function
containing code is already too long...
alternatively,
provide(foo(item)) where:
start_to_generate_an_item()
if flag():
# Are there reasons to return instead of throwing?
raise HigherPriority
item=finish_generation()
Again, I'm not certain that the style should be encouraged, but
neither I am sure it shouldn't be.
-jJ
More information about the Python-ideas
mailing list