pytave: py.foo support

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pytave: py.foo support

Colin Macdonald-2
Mike,

This is awesome!  I tried this a long time ago but I found I couldn't do
"subsref" on the static class (I had to instantiate a `py = pyfactory()`
sort of hack before `py.foo` would call `subsref`).

I read your code but I don't see the secret?  Maybe I tried with a
classdef style class...  or just general incompentence on my part!

Anyway, its very nice!

Colin

Reply | Threaded
Open this post in threaded view
|

Re: pytave: py.foo support

Mike Miller-4
On Thu, Jul 28, 2016 at 15:57:45 -0700, Colin Macdonald wrote:
> Mike,
>
> This is awesome!  I tried this a long time ago but I found I couldn't do
> "subsref" on the static class (I had to instantiate a `py = pyfactory()`
> sort of hack before `py.foo` would call `subsref`).
>
> I read your code but I don't see the secret?  Maybe I tried with a classdef
> style class...  or just general incompentence on my part!

Exactly, old-style class vs classdef. I tried both as well until I got
something that worked ;)

I think this is because classdef handle classes can have static methods,
so py.foo would be a method call on the class, but for old-style classes
it's interpreted the same as py().foo.

I thought we might be getting to the point where this would work, and it
turned out to be pretty easy.

> Anyway, its very nice!

I hope it is fun and useful to everyone, and the Python syntax
immediately becomes a lot nicer to deal with.

  sys = py.sys ## equivalent to "import sys" in Python
  disp (sys.version)
  s = sys.stdin.readline ()
  py.os.uname ()

Still some interesting differences and problems to work out, help is
always welcome.

--
mike