On Friday, March 27, 2015 at 3:39:38 PM UTC-4, LoveWeb2py wrote: > > Hi JorgeH, > > I didn't want to use eval due to code injection, but here is what I ended > up using and it worked. > > field_list = ['db.mytable.field1', 'db.mytable.field2'] > > fields = [getattr(db.mytable, i.split(".")[-1] for i in field_list] > > Note, you don't need to use getattr() -- just do:
[db.mytable[i.split('.')[-1]] for i in field_list] A better option might be to change the function that returns the list so it returns just the field names (why does it need to return fields in 'db.mytable.field1' format?). Anthony -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.