[web2py] Re: Iterate through form.vars

2011-09-07 Thread Noel Villamor
Thanks for the info Anthony. Denes, you just added a trick to my python arsenal. TY. Noel

[web2py] Re: Iterate through form.vars

2011-09-07 Thread DenesL
arr = [ form.vars['x%s'%x] for x in range(3) ] On Sep 6, 11:48 pm, 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

[web2py] Re: Iterate through form.vars

2011-09-07 Thread Anthony
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