*[f for f in db.mytable if f.name in fields] The above is a list comprehension. It returns a list of field objects from the db.mytable table -- including only the fields whose names are found in "fields". The * in front of the list causes the .factory() method to treat each item in the list as a separate argument (rather than taking the entire list as a single argument) -- this is equivalent to manually entering each field as a separate argument to .factory().
With three tables, you could produce a similar list by looping over the tables and then the fields in the tables, or if you really like list comprehensions: mytables = ['table1', 'table2', 'table3'] form_fields = [] [form_fields.extend([db[t][f] for f in db[t].fields if f in fields]) for t in mytables] form = SQLFORM.factory(*form_fields) Anthony On Tuesday, August 21, 2012 12:55:10 AM UTC-4, Don_X wrote: > > How can I re-write the lines of code : > > *if isinstance(fields,tuple): > form = SQLFORM.factory(*[f for f in db.mytable if f.name in fields]) > * > > to take into account my 3 tables ??? ... that is my real problem ! > > > --

