# HG changeset patch # User Mike Miller # Date 1469829084 25200 # Node ID e4175c38b0122ae3afb16dd4e9cc4ffa4b12fdd1 # Parent 24faaa3cf5e5fc9636e58c7e1da11c6b56c220eb 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. diff -r 24faaa3cf5e5 -r e4175c38b012 @py/subsref.m --- a/@py/subsref.m Fri Jul 29 14:39:27 2016 -0700 +++ b/@py/subsref.m Fri Jul 29 14:51:24 2016 -0700 @@ -42,7 +42,15 @@ error ("py: invalid indexing type"); endif - y = pycall ("__import__", subs); + if (type == "." && ((numel (idx) == 1) || (idx(2).type != "."))) + try + y = pyeval (subs); + catch + y = pycall ("__import__", subs); + end_try_catch + else + y = pycall ("__import__", subs); + endif if (numel (idx) > 1) y = subsref (y, idx(2:end));