Mercurial > pytave
comparison @pyobject/methods.m @ 284:6c133bcac33a
use pyobject instead of accessing the InOct dict
* @pyobject/fieldnames.m: Use our tools.
* @pyobject/methods.m: Use our tools.
* @pyobject/pyobject.m (@pyobject/whatclass): Use our tools.
author | Colin Macdonald <cbm@m.fsf.org> |
---|---|
date | Tue, 02 Aug 2016 00:03:51 -0700 |
parents | e61bee04f468 |
children | 06a4b461b141 |
comparison
equal
deleted
inserted
replaced
280:3bf799e80ca5 | 284:6c133bcac33a |
---|---|
66 | 66 |
67 | 67 |
68 function mtds = methods (x) | 68 function mtds = methods (x) |
69 | 69 |
70 # filter the output of `dir(x)` to get callable methods only | 70 # filter the output of `dir(x)` to get callable methods only |
71 cmd = sprintf (["[a for x in (__InOct__['%s'],) for a in dir(x) " ... | 71 cmd = pyeval (["lambda x: [a for a in dir(x)" ... |
72 " if callable(getattr(x, a))" ... | 72 " if callable(getattr(x, a)) and not a.startswith('__')]"]); |
73 " and not a.startswith('__')]"], | |
74 getid (x)); | |
75 | 73 |
76 # FIXME: may need to convert from Python list to Octave cell array | 74 # FIXME: may need to convert from Python list to Octave cell array |
77 mtds_list = pyeval (cmd); | 75 mtds_list = pycall (cmd, x) |
78 | 76 |
79 if (nargout == 0) | 77 if (nargout == 0) |
80 ## FIXME: should this be available as @pyobject/ismodule.m ? | 78 ## FIXME: should this be available as @pyobject/ismodule.m ? |
81 is_module = pyeval ("lambda x: isinstance(x, __import__('types').ModuleType)"); | 79 is_module = pyeval ("lambda x: isinstance(x, __import__('types').ModuleType)"); |
82 | 80 |