Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listing badges #44

Open
foobarbecue opened this issue Feb 9, 2016 · 1 comment
Open

listing badges #44

foobarbecue opened this issue Feb 9, 2016 · 1 comment

Comments

@foobarbecue
Copy link

.badges docstring says it returns users, but actually it just seems to return the badge object. Is this the intended behavior?

In [60]: so = stackexchange.Site('stackoverflow')

In [61]: so.badges?
Type:       instancemethod
String Form:<bound method Site.badges of <stackexchange.Site object at 0x7fc1150b3210>>
File:       /home/aaron/sandbox/Py-StackExchange/demo/build/bdist.linux-x86_64/egg/stackexchange/__init__.py
Definition: so.badges(self, ids=None, **kw)
Docstring:  Returns the users with the badges with IDs.

In [62]: so.badges(22)
Out[62]: (<Badge 'Great Question' @ 7fc1150b3d90>)
lucjon added a commit that referenced this issue Feb 21, 2016
Fixed the documentation issue pointed out in issue #44, and various
implementation issues with the badge recipients methods (probably caused
by differences from API v1.x, although this is hard to verify now it is
offline).
@lucjon
Copy link
Owner

lucjon commented Feb 21, 2016

Sorry for the late reply, thanks a lot for pointing this out to me. That is indeed a documentation issue, which I've fixed in the latest commit.

While digging into it, however, there were a few other issues with the badge methods which should now be fixed in the latest commit. If you want to get the recipients of a particular badge, you can use the recipients field of the Badge object, e.g. so.badge(22).recipients. Bear in mind this is an 'infinite' generator, so don't try and turn it into a list all at once. For something closer to the documented API endpoint, the Site#badge_recipients method returns a set of Badges as described here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants