form.vars (as well as request.vars) is an instance of the Storage class, which inherits from dict (see http://web2py.com/book/default/chapter/04#request for some details about Storage objects). So, you can use regular Python dict methods on form.vars. For example, to get a list of the values of the variables in form.vars, just do:
form.vars.values() Note, however, that Python dictionaries do not preserve order, so the order of the values yielded by the above line may not be as expected. If you want to know the order, you can get the variable names associated with the values (in the same order) with: form.vars.keys() To specify the order yourself, you could do something like: [form.vars[var] for var in ('x0','x1','x2')] Also, note that form.vars will also include values for the hidden fields (i.e., _formname and _formkey), which you may or may not want. Anthony On Tuesday, September 6, 2011 11:48:29 PM UTC-4, Noel Villamor wrote: > > Code: > if form.accepts(request.vars, session): > arr = ['a','b','c'] > for i in range(3): > arr[i] = form.vars.x???? > > Desired: > In the for loop, I wanted to have > arr[0] = form.vars.x0 > arr[1] = form.vars.x1 > arr[2] = form.vars.x2 > > As you can see, I am not yet a pythonista. > > :) > > Thanks! >