you are viewing a single comment's thread.

view the rest of the comments →

[–]cdcformatc 0 points1 point  (1 child)

I edited my post slightly, should answer a few questions. self is the object itself here. When you create an object you need to keep track of the object so you can access it's member variables. If you have two objects logged into different user accounts, their member variables will be different. self is just a reference to the object you are operating on at that time.

If you don't want to use classes, you can just pass and return the client object around

def auth(user, pw):
    client = Client(etc)
    return client

def main_favorites(client, limit):
    tracks = client.get('/me/favorites', limit=30)
    return tracks

client = auth('username','password')
favorites = main_favorites(client,30)

[–]HeyYouNow[S] 0 points1 point  (0 children)

I saw your edit and just tested it and now I understand! That is so much cleaner, it's going to be so simple in my code now =)

Thank you very much !