Mercurial > pytave
comparison @pyobject/methods.m @ 367:9d7188514f2c
Use pyobject.isa instead of lambda to check Python types
* @py/subsref.m, @pyobject/methods.m, @pyobject/pyobject.m,
@pyobject/subsasgn.m, @pyobject/subsref.m: Use pyobject.isa to check Python
types more efficiently.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Thu, 25 Aug 2016 15:26:32 -0700 |
parents | 087e7bc3697f |
children | 0e4097c66788 |
comparison
equal
deleted
inserted
replaced
366:5c900b8383c4 | 367:9d7188514f2c |
---|---|
73 mtds_list_obj = pycall (cmd, x); | 73 mtds_list_obj = pycall (cmd, x); |
74 | 74 |
75 mtds_list = cellfun (@char, cell (mtds_list_obj), "uniformoutput", false); | 75 mtds_list = cellfun (@char, cell (mtds_list_obj), "uniformoutput", false); |
76 | 76 |
77 if (nargout == 0) | 77 if (nargout == 0) |
78 ## FIXME: should this be available as @pyobject/ismodule.m ? | 78 if (isa (x, "py.types.ModuleType")) |
79 is_module = pyeval ("lambda x: isinstance(x, __import__('types').ModuleType)"); | |
80 | |
81 if (pycall (is_module, x)) | |
82 modulename = char (pycall ("getattr", x, "__name__")); | 79 modulename = char (pycall ("getattr", x, "__name__")); |
83 printf ("Methods for Python module '%s':\n", modulename); | 80 printf ("Methods for Python module '%s':\n", modulename); |
84 else | 81 else |
85 ## FIXME: should be `class (x)` | 82 ## FIXME: should be `class (x)` |
86 classref = pycall ("getattr", x, "__class__"); | 83 classref = pycall ("getattr", x, "__class__"); |