Python の優れた点の 1 つは、メソッドと関数をイントロスペクションできることです。例として、関数の署名を取得するにmath.log
は (ipython で) 次を実行します。
In [1]: math.log?
Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in function log>
Namespace: Interactive
Docstring:
log(x[, base])
Return the logarithm of x to the given base.
If the base not specified, returns the natural logarithm (base e) of x.
そしてx
、オプションbase
で がこの関数のパラメータであることを確認してください。
新しい gtk3 と自動で生成された pygobject bindings(*args, **kwargs)
を使用すると、試したすべての例で、すべての gtk メソッドのパラメーターとして取得することしかできません。
例:文字列を必要とするLabel.set_text :
In [1]: from gi.repository import Gtk
In [2]: mylabel = Gtk.Label("hello")
In [3]: mylabel.set_text?
Type: instancemethod
Base Class: <type 'instancemethod'>
String Form: <bound method Label.set_text of <Label object at 0x275b230 (GtkLabel at 0x28cd040)>>
Namespace: Interactive
File: /usr/lib/python2.7/dist-packages/gi/types.py
Definition: L.set_text(*args, **kwargs)
Docstring:
<no docstring>
ここでの質問: これ (Python バインディングのメソッド イントロスペクションの喪失) は、もう一度変更されるもの (ドキュメント) の努力が pygobjects に費やされたのか、それとも pygobjects の動作方法のためにここに残っているものなのか?