Or if you ultimately do need a list of dictionaries, call .as_list() after 
first creating labelList.

On Monday, September 12, 2016 at 7:32:03 AM UTC-4, Niphlod wrote:
>
> as list returns a proper dictionary, not a list of Row objects. At this 
> point, as_list() in your code is superflous. But if you want to use it, you 
> then have to access "myLabel" as row['myLabel']
>
> On Monday, September 12, 2016 at 10:11:46 AM UTC+2, Annet wrote:
>>
>> I have the following query:
>>
>> rows = 
>> db(db.ntw_edge_label_set.vertexID==vertexID).select(db.ntw_edge_label_set.myLabel).as_list()
>>
>> which returns:
>>
>> [{'myLabel': 'NASM Personal Trainers'}, {'myLabel': 'Traineeship'}] 
>>
>> when I try:
>>
>> labelList = [row.myLabel for row in rows]
>>
>> I get the following error:
>>
>> File "/Users/iannet/web2py/applications/com/controllers/network.py" 
>> <http://127.0.0.1:8000/admin/default/edit/com/controllers/network.py>, line 
>> 270, in network_out
>>     labelList = [row.myLabel for row in rows]
>> AttributeError: 'dict' object has no attribute 'myLabel'
>>
>>
>> I don't see why this error occurs. What I want is:
>>
>> ['NASM Personal Trainers', 'Traineeship']
>>
>>
>> Kind regards,
>>
>> Annet
>>
>>
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to