Apart from the fact that I don't think blocks are needed for any of the above, I feel compelled to poke a hole in one of your examples: On Mon, Mar 9, 2009 at 2:47 PM, tav <tav@espians.com> wrote:
# Django/App Engine Query
Frameworks like Django or App Engine define DSLs to enable easy querying of datastores by users. Wouldn't it better if this could be done in pure Python syntax?
Compare the current Django:
q = Entry.objects.filter(headline__startswith="What").filter(pub_date__lte=datetime.now())
with a hypothetical:
using Entry.filter do (entry): if entry.headline.startswith('What') and entry.pub_date <= datetime.now(): return entry
Wouldn't the latter be easier for a developer to read/maintain?
Probably, but it doesn't matter, since Django lazily evaluates chained querys, and doesn't actually evaluate anything until you tell it you want elements. I don't believe there's any way to do this with blocks. -- Cheers, Leif