Skip to content

Instantly share code, notes, and snippets.

@zzzeek
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zzzeek/9436573 to your computer and use it in GitHub Desktop.
Save zzzeek/9436573 to your computer and use it in GitHub Desktop.
>>>> 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