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

New utility: is_bound_method #342

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

plammens
Copy link

The behaviour of inspect.ismethod is inconsistent between Python 3 and 2. In Python 3, it returns True only for bound methods (since there's no way to tell whether a function object is an unbound method), while in Python 2 it returns True for both bound and unbound.

This PR adds an is_bound_method utility which returns True iff the object is callable and is a bound method (either instance- or class-).

Also added tests for this.

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

Successfully merging this pull request may close these issues.

1 participant