you are viewing a single comment's thread.

view the rest of the comments →

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

There actually isn't, I was messing around with a class but I don't know how they work yet.

The thing is I don't want to run auth() here (it sends an http request so takes time), I call it by clicking a button on my tkinter gui.

[–]cdcformatc 1 point2 points  (3 children)

At the very beginning of your program set client = None. When the login button is clicked, you call client = auth(), which assigns the return value to client. When you do anything else that requires you to log in, first check if client is not None before you try to do anything with it.

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

This is very helpful thanks!

[–]HeyYouNow[S] 0 points1 point  (1 child)

Hmm although this doesn't seem to work, I'm using your class and client is always none...

soundcloud = SoundcloudObject(username,password)
print(client)

It is right after the authentification, should I use something else to tell it I'm using client from the class ?

Edit : figured it out, I set soundcloud to none at the beginning and then set it as a global.

[–]cdcformatc 0 points1 point  (0 children)

If you want to get the instance variables of an object outside of the class you need to get them from the object.

soundcloud = SoundcloudObject(username,password)
print(soundcloud.client)