On Mon, May 2, 2011 at 5:48 PM, christian <oz...@web.de> wrote: > Hi, > > from some radio buttons in a django app i concat string like that: > But have no idea how i get the or when there different values > for a specified p column (# is currently my intended splitter maybe i > can concat a better input?). > > input: "p2=1#p2=2#p1=3#p1=1#p1=5#pc=1#py=1" > > output: "p2 in ('1','2') and p1 in ('3','1','5') and pc in ('1') and > py in ('1')"
Start by splitting the string and iterating: for el in input.split('#'): (obviously your variable won't want to be called 'input' but you knew that already) Then split on the = sign and add to a list or dictionary. Be wary of elements that don't have an equals sign in them. That looks like the querystring straight from the GET form, where you're using tickboxes. You could quite happily use '&' as your primary delimiter, if that's the case. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list