0

With Python, I have a userlist with a bunch of userids [1234,321,1203,2348,45955] and so forth. I'm trying to pass the userids into the api.LookupUser function.

This function usually takes one user_id at a time. For example, api.LookupUser(user_id=123)

Is there an easy way to pass each value from the userlist into the function?

New
  • 25
  • 1
  • 1
  • 8

1 Answers1

0

I think you are looking for this

users = (api.LookupUser(user_id=x) for x in userids) 

Or, at least in Python3,

users = map(api.LookupUser, userids) 

And these return a generator, so you'll call next(users) to get the next value. I believe this also delays the API call, so you aren't getting all the users at once and bogging down the API

So, looping though that generator

for u in users:
    print(u) 
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245