http://docs.python.org/tutorial/controlflow.html#tut-unpacking-arguments
* is a python reserved keyword that when placed in front of a list or tuple, it means "Unpack this list" ** does the same, but unpacks a dictionary into variables. so if you do something like def afunc(var1, var2, var3, var4, var5): pass tup = (1,2,3,4,5) afunc(*tup) it will actually call this instead afunc(1,2,3,4,5) and d = dict(a=1, b=2, c=3) bfunc(**d) will actually call it like bfunc(a=1, b=2, c=3) You can mix and match when calling fucntions cfunc(*tup, **d) --> cfunc(1,2,3,4,5,a=1,b=2,c=3) -Thadeus On Thu, Oct 29, 2009 at 10:36 AM, Chris S <sanders.ch...@gmail.com> wrote: > > lol, well I've been all around that. Thank you so much, works just > fine now. > > Is there a quick 2-min "why that works" or somewhere you could point > me to as to what that * means/does? Apparently I'm missing out on > something important. > > On Oct 29, 10:33 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > form=SQLFORM.factory(*[fields[num] for num in range(len(fields))]) > > > > On Oct 29, 10:25 am, Chris S <sanders.ch...@gmail.com> wrote: > > > > > I've been trying to get a form built where the number of Fields are > > > dynamic. I was successful with the plan form by using: > > > ------------Form Implementation------------------------ > > > fields=[] > > > for item in list: > > > fields.append(item) > > > fields.append(INPUT(_name=item,requires=IS_INT_IN_RANGE > > > (0,100,error_message=('Must be an Int 0 to 100')))) > > > fields.append(INPUT(_type='submit')) > > > > > form=FORM([fields[num] for num in range(len(fields))]) > > > ------------Form Implementation------------------------ > > > > > I can append items to my form but the output in HTML is nasty. > > > Everything is just crammed together. I read about form.custom and was > > > going to use that approach but apparently I have to use the > > > SQLFORM.factory() to use that. Attempting the same thing in > > > SQLFORM.factory() looks like > > > > > ------------SQLFORM.factory() Implementation------------------------ > > > fields.append(Field('item1')) > > > fields.append(Field('item2')) > > > > > form=SQLFORM.factory(fields[0]) > > > #This works, but obviously isn't dynamic I only get the first entry. > > > > > form=SQLFORM.factory(fields[num] for num in range(len(fields))) > > > #This errors with "define_table argument is not a Field: <generator > > > object at 0x110BD7B0>" > > > ------------SQLFORM.factory() Implementation------------------------ > > > > > Can anyone help me out here? I want to be able to arrange the fields > > > in HTML like I want (which I can't seem to do with just the simple > > > form), but I also want to be able to build the fields dynamically > > > which I can't seem to get working with SQLFORM.factory(). I'm sure > > > I'm missing something easy, this can't be as hard as I'm making it. > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---