2

>>> pdb.gimp_file_load.nparams
3
>>> pprint.pprint(pdb.gimp_file_load.params)
((0,
  'run-mode',
  'The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }'),
 (4, 'filename', 'The name of the file to load'),
 (4, 'raw-filename', 'The name as entered by the user'))
>>> fname = 'a filename'
>>> img = pdb.gimp_file_load(gimpfu.RUN_NONINTERACTIVE, fname, fname)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: wrong number of parameters

それで、私はここで何が間違っていますか?メソッド自体によると、3 つの十分に文書化された引数が必要です。必要な 3 つのものを渡すと、TypeError. そう:

  1. 私は何を間違っていますか?
  2. これに関するリファレンスマニュアルはありますか?
  3. 引数のタプルには、0、4、および 4 があります。これらの魔法の定数とは何ですか? docsによると、これらは次のように見えます。

    パラメーターの型 (PARAM_* 定数の 1 つ)

    しかし、これらのドキュメントのどこにもPARAM_定数が見つかりません。また、pdb、gimp、または gimpfu のいずれかをイントロスペクトしているのも見つかりませんでした。

完全にするために: 明らかな ,help(pdb.gimp_file_load)はあまり役に立ちません:

>>> help(pdb.gimp_file_load)
Help on PDBFunction object:

class PDBFunction(__builtin__.object)
 |  Methods defined here:
 |  
 |  __call__(...)
 |      x.__call__(...) <==> x(...)
 |  
 |  __repr__(...)
 |      x.__repr__() <==> repr(x)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  nparams
 |  
 |  nreturn_vals
 |  
 |  params
 |  
 |  proc_author
 |  
 |  proc_blurb
 |  
 |  proc_copyright
 |  
 |  proc_date
 |  
 |  proc_help
 |  
 |  proc_name
 |  
 |  proc_type
 |  
 |  return_vals
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __new__ = <built-in method __new__ of type object>
 |      T.__new__(S, ...) -> a new object with type S, a subtype of T
4

2 に答える 2