Thread Subject: Calling a Python COM object from MATLAB

Subject: Calling a Python COM object from MATLAB

From: Santiago Balestrini

Date: 18 Jun, 2009 22:00:04

Message: 1 of 3

Okay, so I need to call a Python COM object from MATLAB. I can do it from Excel just fine, but when I use ACTXSERVER it seems to load it but when queried for methods and other things it just seems to be empty.

In MATLAB I type the call below to get a handle h to the Python object (the Python code is at the end of the post)

>> h = actxserver('python.try2')
 
h =
 
COM.python_try2

when I use the methods function to see what methods the object has, I only get the MATLAB ones:

>> methods(h)

Methods for class COM.python_try2:

addproperty deleteproperty interfaces move save
constructorargs events invoke propedit send
delete get load release set


This is the Python test code:

class PythonUtilities:
    _public_methods_ = ['hello']
    _reg_progid_ = "Python.Try2"
    _reg_clsid_ = "{19353e9b-964a-4b1c-8cd1-baccc0209af3}"
    
    def hello(self, string):
        return string

if __name__=='__main__':
    print "Registering COM server..."
    import win32com.server.register
    win32com.server.register.UseCommandLine(PythonUtilities)

Any ideas are welcome, at the very least, thanks for reading this post.

-Santiago

Subject: Calling a Python COM object from MATLAB

From: Yair Altman

Date: 20 Jun, 2009 19:02:02

Message: 2 of 3

I'm guessing you need to load your Python class object before being able to use it.

In any case, try using my UIINSPECT utility on the file exchange instead of the built-in methods function: http://www.mathworks.com/matlabcentral/fileexchange/17935

Yair Altman
http://UndocumentedMatlab.com
 

Subject: Calling a Python COM object from MATLAB

From: Christopher Taylor

Date: 22 Jun, 2009 18:14:01

Message: 3 of 3

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <h1jbna$t8c$1@fred.mathworks.com>...
> I'm guessing you need to load your Python class object before being able to use it.
>
> In any case, try using my UIINSPECT utility on the file exchange instead of the built-in methods function: http://www.mathworks.com/matlabcentral/fileexchange/17935
>
> Yair Altman
> http://UndocumentedMatlab.com

Hello,
  I am the other person working on this project. Thanks for the reply, when I run your uiinspect, I have the same problem of not being able to see the 'hello' method from the python class. I just get the same methods if I call the built in methods functions. When you say the python class object needs to be loaded, what did you mean by this? I thought that by calling the actxserver('python.try2') function I was loading the python class. Is there something else that I have to do to load the object?
Again thank you for the reply.
-Christopher Taylor

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
python Santiago Balestrini 18 Jun, 2009 18:04:02
com Santiago Balestrini 18 Jun, 2009 18:04:02
actxserver Santiago Balestrini 18 Jun, 2009 18:04:02
rssFeed for this Thread

Contact us at files@mathworks.com