@pbreit
> Can't you just explain to people that this is how you query the db:
>
>       rows = db(db.item.id==1).select()
>
> How much is gained by dropping the "db"?

Programming is all about taking comprehensible pieces and piecing them
together for your own purposes. A rote formula of syntax that you
don't really understand only helps you do that one thing and
superficial variants thereof. Often taking your rote formula and
plugging in different values can get you pretty far, but at some point
it fails, leaving you lost and frustrated. Sometimes, by just
imitating formulas, you'll pick up what's really going on over time,
but not without extra effort, and often you just won't. In short,
programmers shouldn't use their tools (languages, libraries, etc.) as
if they're magic.

So I'm not saying Set is hard to use, I'm saying it's hard to truly
understand. In your example, not only is the DAL instance db being
invoked (which in itself is a weird allowance of Python), invoking a
DAL is the preferred means of producing Set objects rather than the
Set constructor itself. (And keep in mind that these oddities are on
top of producing Query objects from overloaded operators, which is one
of the most confusing features of Python.) Again, though, the main
issue is that Set just doesn't really do anything and so begs
explanation. Sure many students are happy to blindly just imitate a
formula, but that's a bad impulse that should be countered.

I concede that for web2py's current user base, this is a minor point
of null concern, but I feel it's a notable blemish in an otherwise
exceptionally clean and well-thought-out API, and a few blemishes like
this here and there can represent serious learning hurdles.

Reply via email to