Есть такой код:
result = db.query("SELECT SUM(x) AS x, SUM(y) AS y FROM ...)
print result[0].x
print result[0].y
Вываливает такую ошибку:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.5/web/application.py", line 242, in process
return self.handle()
File "/usr/lib/pymodules/python2.5/web/application.py", line 233, in handle
return self._delegate(fn, self.fvars, args)
File "/usr/lib/pymodules/python2.5/web/application.py", line 412, in _delegate
return handle_class(cls)
File "/usr/lib/pymodules/python2.5/web/application.py", line 387, in handle_class
return tocall(*args)
File "/home/turbid/workspace/AReport/src/code.py", line 57, in POST
print result[0].y
File "/usr/lib/pymodules/python2.5/web/utils.py", line 476, in __getitem__
raise IndexError, "already passed "+str(i)
IndexError: already passed 0
Если же сделать так:
result = db.query("SELECT SUM(x) AS x, SUM(y) AS y FROM ...)
res = result[0]
print res.x
print res.y
То все норм. В чем wtf?
p.s.
print type(result[0])
<class 'web.utils.Storage'>