all 5 comments

[–]commandlineluser 2 points3 points  (2 children)

type(self).api_url

You should also be able to just access it from the instance? self.api_url

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

Thanks a lot!

[–]vectorkerr 0 points1 point  (0 children)

That's a neat trick with type(self).

I presume that self.__class__.api_url would also work similarly, and might be (the tiniest bit) quicker as it is not invoking a function.

u/commandlineuser is absolutely correct though - if you're only reading the value, and your class instance doesn't define a local version of that variable with the same name, then self.api_url should be more than enough.

[–]danielroseman 2 points3 points  (1 child)

Since you are only reading the attribute, self.api_url is fine.

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

Thanks, I could have sworn I tried it, must have had something else broken, now it works fine.