# HG changeset patch # User Mike Miller # Date 1470165062 25200 # Node ID 9e8faa439d1de9ffa323e9b8d65a0b5b1acdacf4 # Parent 46d9b2972901c25c380921f94a97416aa14849ae# Parent 06a4b461b1414786a6137d7413bf9fa6b888b947 Merged in macdonald/pytave (pull request #35) use pyobject instead of accessing the InOct dict diff -r 46d9b2972901 -r 9e8faa439d1d @pyobject/fieldnames.m --- a/@pyobject/fieldnames.m Tue Aug 02 12:04:12 2016 -0700 +++ b/@pyobject/fieldnames.m Tue Aug 02 12:11:02 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 46d9b2972901 -r 9e8faa439d1d @pyobject/methods.m --- a/@pyobject/methods.m Tue Aug 02 12:04:12 2016 -0700 +++ b/@pyobject/methods.m Tue Aug 02 12:11:02 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 46d9b2972901 -r 9e8faa439d1d @pyobject/pyobject.m --- a/@pyobject/pyobject.m Tue Aug 02 12:04:12 2016 -0700 +++ b/@pyobject/pyobject.m Tue Aug 02 12:11:02 2016 -0700 @@ -146,7 +146,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)