0

I am building a SoundCloud music streaming skill for Alexa with Flask-ask in python. I have a generator function that looks like this:

def stream_likes():
   url = "http://api.soundcloud.com/me/favorites?oauth_token={}".format(oauth_token)
   r = requests.get(url)
   response = json.loads(r.text)
   for track in response:
       yield track.url


fav_generator = stream_likes()

When I call next(fav_generator) immediately after the iterator is created, it works fine. However, when I call the function from inside of another function like this:

@ask.intent('FavoritesIntent')
def play_favs():
    stream_url = next(fav_generator)
    return audio().play(stream_url)

I get the following error code.

TypeError: next() takes no arguments (1 given)

I would understand this error if I called a method of a class without passing the self parameter but I don't know why I am getting it in this instance.

Kaushik
  • 235
  • 1
  • 2
  • 12
  • 1
    It looks like you have overwritten the builtin function `next` with your own. Or, maybe, some library did that and you've used `from library import *` – yeputons Feb 21 '17 at 01:17
  • Ah you are correct, It looks like I had a `next()` function in one of the files I was importing. I feel stupid. Thanks! – Kaushik Feb 21 '17 at 01:20

0 Answers0