[Python-ideas] proposal to add rowexpr as a keyword

Blake Winton bwinton at latte.ca
Tue May 29 16:09:11 CEST 2007


Steve Howell wrote:
> Let the Python interpreter build expression objects
> for you.  You write:
>    rowexpr: convert_to_euros(salary) > 50000 and
> deptno = 10
> Python translates that into the same bytecode as:
> lambda row: convert_to_euros(row['salary'] > 50000 and
> row['deptno'] == 10

I'm sorry, why would that not be translated into:

lambda row: row['convert_to_euros'](row['salary'] > row['50000'] 
row['and'] row['deptno'] == row['10']

?  Specifically, how would python know what to dereference and what not 
to?  What if there were two things, named the same, one in the row and 
one in the namespace?  (i.e. a variable named 'salary')  How would you 
escape things which would have been dereferenced but you didn't want to 
be?  (i.e. "rowexpr: convert_to_euros(salary) > salary")

I guess I'm kind of wasting my time here, since the introduction of a 
new keyword for this application really isn't going to happen, based on 
other decisions I've seen Guido make, but I do think that you need to 
think a little more about how the implementation of this feature would 
work.  (Or perhaps you've done that thinking, and you just need to fill 
in the proposal with that information.)

Thanks,
Blake.



More information about the Python-ideas mailing list