[Python-ideas] Ruby-style Blocks in Python Idea [with examples]

Bruce Leban bruce at leapyear.org
Mon Mar 9 20:19:50 CET 2009


> Again, being able to do it in Python syntax will save developers the
> hassles of having to learn non-Python DSLs.

Hmm. For your GqlQuery example, the way I see it doing it in Python syntax
will save the hassle of GqlQuery optimizing the database access. The truth
is that you don't know what happens to the query string but you do know that
it can't take your function apart and have the database process it. So this
example is useless.

I also can't tell if using/do is supposed to be a loop or not. Some of your
examples are loopy and some aren't.

And besides that your examples are apples and oranges:

 composer = "Lennon, John"
 query = GqlQuery("SELECT * FROM Song WHERE composer = :1", composer)

with:

 composer = "Lennon, John"
 using Song.query do (item):
     if item.composer == composer:
         return item

The first one produces a result: something bound to a variable named query.
What does the second one produce? I see no advantage in a new syntax that is
this confusing.

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090309/15cecad3/attachment.html>


More information about the Python-ideas mailing list