[Python-ideas] Assignment decorators (Re: The Descriptor Protocol...)

Boris Borcic bborcic at gmail.com
Sat Mar 12 14:22:31 CET 2011


Cesare Di Mauro wrote:
> 2011/3/11 MRAB <python at mrabarnett.plus.com
> <mailto:python at mrabarnett.plus.com>>
[...]

>     Clearly it's a method, so the instance would be passed as 'self',
>     something like this:
>
>         def insert(self, date, trans, symbol, qty, price) from sqlite3:
>             insert into stocks values (date, trans, symbol, qty, price)
>
>     but what happens to 'self' within the definition? It's not referred to
>     in the SQL statement itself.
>
>
> I already do something like this:
>
> DB.stocks += '2006-01-05', 'BUY', 'RHAT',100, 35.14
>
> DB.stocks -= ID == 123
>
> DB.stocks[ID == 123] = qty == qty + 1, price == 46.51
>
> print DB.stocks[date,
> 'COUNT(*)'].GroupBy[date].OrderBy[date].Where[date['2011-01-01' :
> '2011-02-28']].List()
>
> with Python 2.5+.
>
> So there's no need for a new syntax to implement such things in a
> "pythonic" way.

As neat as this looks, IMO this is a misunderstanding on

(1) a pythonic way to invite foreign language code and syntax
     into python source code

(2) a pythonic way to hide SQL semantics under python syntax.

Tkinter did for tcl what SQLAlchemy does for SQL, and I feel both reveal a 
challenge for python to be more open to foreign code syntax. iow return to 
Caesar what's Caesar's.

Cheers, BB




More information about the Python-ideas mailing list