> > That syntax works and I can use that to refer to the data, I could see > that a row object had an '_extra' dict for the selected expressions > but could not see that the data could be referred to be the name of > the expression 'mysum' (its in there somewhere but not sure where!!) >
The book example does show that usage: >>> sum = db.log.severity.sum() >>> print db().select(sum).first()[sum] Actually, when you do row[mysum], the __getitem__ method of the Row object automatically does row[str(mysum)]. Since mysum is a DAL Expression object, its __str__ method converts it to the SQL syntax for the particular database adapter you are using, which in this case is "(SUM(t_appointment.miles_to) + SUM(t_appointment.miles_from))". The Row __getitem__ method first looks for that key in its _extra dict and returns the value if found. So, when you do: row[mysum] This is essentially what is happening behind the scenes: 1. row[str(mysum)] 2. row['(SUM(t_appointment.miles_to) + SUM(t_appointment.miles_from))'] 3. row['_extra']['(SUM(t_appointment.miles_to) + SUM(t_appointment.miles_from))'] Anthony

