1

I am a python beginner and I currently struggle with some (probably quite simple) stuff. I would like to know the default parameters of a python function, more specifically of cv2.ORB_create().

With the following code I managed to see the 'documentation string':

import cv2
orb = cv2.ORB_create()
print(cv2.ORB_create.__doc__)

However, print(cv2.ORB_create.__defaults__) just gives me an error;

AttributeError: 'builtin_function_or_method' object has no attribute '__defaults__'

Maybe I am missing a link between functions, modules, etc. but I am really stuck...

Since the concern was brought up that this is a duplicate. I also tried inspect.signature and by extension inspect.getargspec, but this give me another error ValueError: no signature found for builtin <built-in function ORB_create>.

user73202
  • 23
  • 5
  • Sorry, I forgot to mention that `inspect.signature` and by extension `inspect.getargspec` also failed. So the other answers do not / did not help me. – user73202 Dec 26 '17 at 13:02

1 Answers1

0

cv2.ORB_create() seems to be a function written with the Python extensions (In C instead of Python). As such, it isn't a "normal" function object, and there is no way to see the default values reliably (As it is handled manually in C).

One possible solution would be to look at the __text_signature__ attribute, but this may not be reliable. See What are __signature__ and __text_signature__ used for in Python 3.4.

Artyer
  • 31,034
  • 3
  • 47
  • 75
  • Thanks, that explains my issue. Unfortunatelly, `__text_signature__` returns None. But I will have a closer look at you link. – user73202 Dec 26 '17 at 12:41