Converting an array to a csv in script

so when I read the selected rows from a drop down it gives it to me in this format
: [u’Admin’, u’role101’, u’fgf’, u’uio’, u’oooo’, u’ghggggg’]

But QueryString likes data in the following format
‘Admin’,‘role101’,‘fgf’,‘uio’,‘oooo’,‘ghggggg’

Right not I am doing alot of for loops and replace funtions to get to that format.

Is it possible to convert it from arraywrapper to the way QueryString wants it’s input in a much cleaner way?

This is just a toString representation of a list object containing string members.

If you want to join those into a string that contains quoted and comma-separated values you can use something like this:

l = ['foo', 'bar', 'baz']
quoted = map(lambda x: "'%s'" % x, l)
joined = ",".join(quoted)

print joined # prints 'foo','bar','baz'

Or if you want a one-liner:

l = ['foo', 'bar', 'baz']
joined = ",".join("'%s'" % item for item in l)