Last active
August 29, 2015 13:57
-
-
Save zzzeek/9436573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>>> x = object | |
>>>> inspect.isbuiltin(x) | |
False | |
>>>> inspect.isclass(x) | |
True | |
>>>> inspect.isbuiltin(x.__init__) | |
False | |
>>>> inspect.ismethod(x.__init__) | |
True | |
>>>> inspect.getargspec(x.__init__) | |
ArgSpec(args=['obj'], varargs='args', keywords='keywords', defaults=None) | |
# claims to take varargs and keywords huh? | |
>>>> x('4', foo='bar') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: default __new__ takes no parameters | |
# its not a straight up function that accepts the args | |
# it claims. What is the universal always-works way to | |
# detect functions or constructors that aren't straight | |
# up user-defined functions? in cPython, isbuiltin() works great. | |
>>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment