# HG changeset patch # User Colin Macdonald # Date 1470121431 25200 # Node ID 6c133bcac33a51b43aa53ef684424edbec40b105 # Parent 3bf799e80ca5110df2871bf955c8b6eda09a862f 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. diff -r 3bf799e80ca5 -r 6c133bcac33a @pyobject/fieldnames.m --- a/@pyobject/fieldnames.m Fri Jul 29 20:15:39 2016 -0700 +++ b/@pyobject/fieldnames.m Tue Aug 02 00:03:51 2016 -0700 @@ -47,14 +47,13 @@ function names = fieldnames (x) - cmd = sprintf (["[a for x in (__InOct__['%s'],) for a in dir(x) " ... - " if not callable(getattr(x, a))" ... - " and not isinstance(getattr(x, a), __import__('types').ModuleType)" ... - " and not a.startswith('_')]"], - getid (x)); + cmd = pyeval (["lambda x: [a for a in dir(x)" ... + " if not callable(getattr(x, a))" ... + " and not isinstance(getattr(x, a), __import__('types').ModuleType)" ... + " and not a.startswith('_')]"]); # FIXME: may need to convert from Python list to Octave cell array - names = pyeval (cmd); + names = pycall (cmd, x); names = names(:); endfunction diff -r 3bf799e80ca5 -r 6c133bcac33a @pyobject/methods.m --- a/@pyobject/methods.m Fri Jul 29 20:15:39 2016 -0700 +++ b/@pyobject/methods.m Tue Aug 02 00:03:51 2016 -0700 @@ -68,13 +68,11 @@ function mtds = methods (x) # filter the output of `dir(x)` to get callable methods only - cmd = sprintf (["[a for x in (__InOct__['%s'],) for a in dir(x) " ... - " if callable(getattr(x, a))" ... - " and not a.startswith('__')]"], - getid (x)); + cmd = pyeval (["lambda x: [a for a in dir(x)" ... + " if callable(getattr(x, a)) and not a.startswith('__')]"]); # FIXME: may need to convert from Python list to Octave cell array - mtds_list = pyeval (cmd); + mtds_list = pycall (cmd, x) if (nargout == 0) ## FIXME: should this be available as @pyobject/ismodule.m ? diff -r 3bf799e80ca5 -r 6c133bcac33a @pyobject/pyobject.m --- a/@pyobject/pyobject.m Fri Jul 29 20:15:39 2016 -0700 +++ b/@pyobject/pyobject.m Tue Aug 02 00:03:51 2016 -0700 @@ -110,7 +110,8 @@ endfunction function s = whatclass (x) - s = pyeval (sprintf ("str(__InOct__['%s'].__class__)", x.id)); + idx = struct ("type", ".", "subs", "__class__"); + s = subsref (x, idx); endfunction function vargout = help (x)