comparison @py/subsref.m @ 276:e4175c38b012

py: handle calling builtin functions with "py.foo" syntax (fixes issue #43) * @py/subsref.m: Attempt to evaluate name as a builtin function or type before attempting to import it as a module.
author Mike Miller <mtmiller@octave.org>
date Fri, 29 Jul 2016 14:51:24 -0700
parents 8ebebd557e15
children 3bdd924a5fc7
comparison
equal deleted inserted replaced
275:24faaa3cf5e5 276:e4175c38b012
40 40
41 if (type != ".") 41 if (type != ".")
42 error ("py: invalid indexing type"); 42 error ("py: invalid indexing type");
43 endif 43 endif
44 44
45 y = pycall ("__import__", subs); 45 if (type == "." && ((numel (idx) == 1) || (idx(2).type != ".")))
46 try
47 y = pyeval (subs);
48 catch
49 y = pycall ("__import__", subs);
50 end_try_catch
51 else
52 y = pycall ("__import__", subs);
53 endif
46 54
47 if (numel (idx) > 1) 55 if (numel (idx) > 1)
48 y = subsref (y, idx(2:end)); 56 y = subsref (y, idx(2:end));
49 endif 57 endif
50 58