On Thursday, November 3, 2011 8:31:10 PM UTC-4, Bianca Cadaveri wrote: > > Thank you very much to both of you. > > Is this way to write formats specific to Web2py : '%(first_name) % > (last_name) (%(id))' ? > > I have never met before "%" followed by "()". > > It means : write "first_name last_name" corresponding to "id", right ?
Not exactly. This is standard Python string formatting: http://docs.python.org/library/stdtypes.html#string-formatting The string above should be followed by a % and then a dictionary with keys equal to the placeholders in parentheses (in this case, first_name, last_name, and id) and values equal to the values you want to substitute into the string. When you specify the 'format' argument of a table in this way, web2py will pass the Row object for the record as the dictionary (the Row class inherits from dictionary, so functions as a dictionary in this case), so the values from the record will get substituted for the field names in the 'format' string. The output of the above would be something like 'John Doe (1)' (the name is John Doe and the record id is 1). Alternatively, the format argument can be a function that takes a single Row object and returns the desired output. Anthony

