[Tutor] Convert a list to a group of separated strings
Juan Christian
juan0christian at gmail.com
Thu Sep 11 18:42:49 CEST 2014
Let's say I have the following list: my_list = ['76561198048214059',
'76561198065852182', '76561198067017670', '76561198077080978',
'76561198077257977', '7656119807971
7745', '76561198088368223', '76561198144945778']
and I have a function with the following signature: def
fetch_users(*steamids)
Usage: fetch_users("76561198048214059", "76561198065852182",
"76561198067017670", [...])
Inside the 'fetch_users' function I have a call to the API using this
approach: req = urllib.request.urlopen('API_URL_HERE&steamids=' +
','.join(steamids))
This way I call the API with the following URL (example):
API_URL_HERE&steamids=76561198048214059,76561198065852182
And everything works.
The problem is that when I give the 'my_list' directly to 'fetch_users'
function it gives me "TypeError: sequence item 0: expected str instance,
list found".
How can I convert it to something like "fetch_users("76561198048214059",
"76561198065852182", "76561198067017670", [...])"
I tried with " ''.join(my_list) " but didn't work. I think it's a very
simple question but I'm struggling to find the answer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140911/34a4b377/attachment.html>
More information about the Tutor
mailing list