I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :
class Fop:
_public_methods_ = [ 'SqVal' ]
def SqVal(self,*val):
#vol=(val[0][0],val[0][1])
#mat1=mat((vol))
#up=linalg.inv(mat1)
return str(val)#up
_reg_verprogid_ = "Python.Fop.3"
_reg_progid_ = "Python.Fop"
_reg_desc_ = "Python Fop"
_reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}"
I pass to this method an array of variant which is the matrix to
invert like that:
vb6 code :
Set obj = CreateObject("Python.Fop")
Dim ty(1, 1) As Variant
ty(0, 0) = 1
ty(1, 0) = 2
ty(0, 1) = 3
ty(1, 1) = 4
toto = obj.SqVal(ty)
when I dispaly toto as str(val) I obtain the following tuple "(((1,
3), (2, 4)),)" which is not usable ....
Do you have an idea to explain this strange behaviour ?
thank you ! 5 3969
En Thu, 03 May 2007 04:54:43 -0300, vml <vi***********@gmail.comescribió:
I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :
class Fop:
_public_methods_ = [ 'SqVal' ]
def SqVal(self,*val):
#vol=(val[0][0],val[0][1])
#mat1=mat((vol))
#up=linalg.inv(mat1)
return str(val)#up
_reg_verprogid_ = "Python.Fop.3"
_reg_progid_ = "Python.Fop"
_reg_desc_ = "Python Fop"
_reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}"
I pass to this method an array of variant which is the matrix to
invert like that:
vb6 code :
Set obj = CreateObject("Python.Fop")
Dim ty(1, 1) As Variant
ty(0, 0) = 1
ty(1, 0) = 2
ty(0, 1) = 3
ty(1, 1) = 4
toto = obj.SqVal(ty)
when I dispaly toto as str(val) I obtain the following tuple "(((1,
3), (2, 4)),)" which is not usable ....
Do you have an idea to explain this strange behaviour ?
This is the expected behaviour. Writing it completely in Python:
pydef SqVal(*val):
.... return str(val)
....
pyty=((1,3),(2,4))
pySqVal(ty)
'(((1, 3), (2, 4)),)'
The *val parameter receives a tuple, whose elements are the positional
arguments used when calling the function. As you call the function with a
single argument, val receives a tuple with a single element.
Perhaps you want to write it as:
pydef SqVal(val):
.... print val[0][0]
.... print val[0][1]
.... print val[1][0]
.... print val[1][1]
....
pySqVal(ty)
1
3
2
4
(Of course, if used as a Fop method, dont forget the "self" parameter)
--
Gabriel Genellina
On 3 mai, 14:20, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Thu, 03 May 2007 04:54:43 -0300, vml <victor.leb...@gmail.comescribió:
I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :
class Fop:
_public_methods_ = [ 'SqVal' ]
def SqVal(self,*val):
#vol=(val[0][0],val[0][1])
#mat1=mat((vol))
#up=linalg.inv(mat1)
return str(val)#up
_reg_verprogid_ = "Python.Fop.3"
_reg_progid_ = "Python.Fop"
_reg_desc_ = "Python Fop"
_reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}"
I pass to this method an array of variant which is the matrix to
invert like that:
vb6 code :
Set obj = CreateObject("Python.Fop")
Dim ty(1, 1) As Variant
ty(0, 0) = 1
ty(1, 0) = 2
ty(0, 1) = 3
ty(1, 1) = 4
toto = obj.SqVal(ty)
when I dispaly toto as str(val) I obtain the following tuple "(((1,
3), (2, 4)),)" which is not usable ....
Do you have an idea to explain this strange behaviour ?
This is the expected behaviour. Writing it completely in Python:
pydef SqVal(*val):
... return str(val)
...
pyty=((1,3),(2,4))
pySqVal(ty)
'(((1, 3), (2, 4)),)'
The *val parameter receives a tuple, whose elements are the positional
arguments used when calling the function. As you call the function with a
single argument, val receives a tuple with a single element.
Perhaps you want to write it as:
pydef SqVal(val):
... print val[0][0]
... print val[0][1]
... print val[1][0]
... print val[1][1]
...
pySqVal(ty)
1
3
2
4
(Of course, if used as a Fop method, dont forget the "self" parameter)
--
Gabriel Genellina
I just tried to replace the *val by SqVal(self,val) and call the
method in vb but it crashes down :
"when refilling safe array the sequence must have the same number of
dimension as the existing array"
my python code is now :
def SqVal(self,val):
## volr=[val[0][0][i] for i in range(size(val,2))]
## voli=[val[0][1][i] for i in range(size(val,2))]
## mat1=mat(volr)+1j*mat(voli)
## up=linalg.pinv(mat1)
## out=up.real.tolist()
## out.extend(up.imag.tolist())
return val
By the way Do you have any idea to debug the com server script ? ( I
would like to know if a can access the value in the function while
calling it from vb 6)
tahnks a lot !
vml wrote:
On 3 mai, 14:20, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
>En Thu, 03 May 2007 04:54:43 -0300, vml <victor.leb...@gmail.comescribió:
>>I have a python com object which contains a method to inverse an array in vb 6 the definition of the class is : class Fop: _public_methods_ = [ 'SqVal' ] def SqVal(self,*val): #vol=(val[0][0],val[0][1]) #mat1=mat((vol)) #up=linalg.inv(mat1) return str(val)#up _reg_verprogid_ = "Python.Fop.3" _reg_progid_ = "Python.Fop" _reg_desc_ = "Python Fop" _reg_clsid_ = "{30BD3490-2632-11cf-AD5B-524153480001}" I pass to this method an array of variant which is the matrix to invert like that: vb6 code : Set obj = CreateObject("Python.Fop") Dim ty(1, 1) As Variant ty(0, 0) = 1 ty(1, 0) = 2 ty(0, 1) = 3 ty(1, 1) = 4 toto = obj.SqVal(ty) when I dispaly toto as str(val) I obtain the following tuple "(((1, 3), (2, 4)),)" which is not usable .... Do you have an idea to explain this strange behaviour ?
This is the expected behaviour. Writing it completely in Python:
pydef SqVal(*val): ... return str(val) ... pyty=((1,3),(2,4)) pySqVal(ty) '(((1, 3), (2, 4)),)'
The *val parameter receives a tuple, whose elements are the positional arguments used when calling the function. As you call the function with a single argument, val receives a tuple with a single element. Perhaps you want to write it as:
pydef SqVal(val): ... print val[0][0] ... print val[0][1] ... print val[1][0] ... print val[1][1] ... pySqVal(ty) 1 3 2 4
(Of course, if used as a Fop method, dont forget the "self" parameter)
-- Gabriel Genellina
I just tried to replace the *val by SqVal(self,val) and call the
method in vb but it crashes down :
"when refilling safe array the sequence must have the same number of
dimension as the existing array"
my python code is now :
def SqVal(self,val):
## volr=[val[0][0][i] for i in range(size(val,2))]
## voli=[val[0][1][i] for i in range(size(val,2))]
## mat1=mat(volr)+1j*mat(voli)
## up=linalg.pinv(mat1)
## out=up.real.tolist()
## out.extend(up.imag.tolist())
return val
By the way Do you have any idea to debug the com server script ? ( I
would like to know if a can access the value in the function while
calling it from vb 6)
tahnks a lot !
Debugging COM objects is best done using logging module or at least
writing to a file during processing. You can review the log file
to see what was going on.
-Larry
En Thu, 03 May 2007 09:41:57 -0300, vml <vi***********@gmail.comescribió:
On 3 mai, 14:20, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
>En Thu, 03 May 2007 04:54:43 -0300, vml <victor.leb...@gmail.com> escribió:
I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :
I just tried to replace the *val by SqVal(self,val) and call the
method in vb but it crashes down :
"when refilling safe array the sequence must have the same number of
dimension as the existing array"
That can't happen with your Python code below, so it must be on the
caller. Maybe you wrote something like: xx=something.SqVal(yy) and xx,yy
are declared of different sizes.
def SqVal(self,val):
## ...
return val
By the way Do you have any idea to debug the com server script ? ( I
would like to know if a can access the value in the function while
calling it from vb 6)
Write a log file as suggested, or use OutputDebugString with the DebugView
program from www.sysinternals.com
--
Gabriel Genellina
On 4 mai, 06:56, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Thu, 03 May 2007 09:41:57 -0300,vml<victor.leb...@gmail.comescribió:
On 3 mai, 14:20, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Thu, 03 May 2007 04:54:43 -0300,vml<victor.leb...@gmail.com>
escribió:
I have a python com object which contains a method to inverse an array
in vb 6 the definition of the class is :
I just tried to replace the *val by SqVal(self,val) and call the
method in vb but it crashes down :
"when refilling safe array the sequence must have the same number of
dimension as the existing array"
That can't happen with your Python code below, so it must be on the
caller. Maybe you wrote something like: xx=something.SqVal(yy) and xx,yy
are declared of different sizes.
It is true that I call the python routine like that in vb :
toto = obj.SqVal(ty)
If I am understanding well I need to pass an array of 2x2 and I should
retireve an array of variant of 2x2 ....
I tried to do that :
vb6 :
Dim obj As Object
Dim toto(1, 1, 2) As Variant
Set obj = CreateObject("Python.Fop")
Dim ty(1, 1, 2) As Variant
ty(0, 0, 0) = 1
ty(0, 1, 0) = 2
ty(0, 0, 1) = 3
ty(0, 0, 2) = 7
ty(0, 1, 1) = 4
ty(0, 1, 2) = 45
ty(1, 0, 0) = 1
ty(1, 1, 0) = 2
ty(1, 0, 1) = 3
ty(1, 0, 2) = 7
ty(1, 1, 1) = 4
ty(1, 1, 2) = 45
toto = obj.SqVal(ty)
but it is saying that the compiler can not assign the array toto at
the line toto=obj.SqVal().... hum strange .....
any ideas ?
Thank you for your help !
def SqVal(self,val):
## ...
return val
By the way Do you have any idea to debug the com server script ? ( I
would like to know if a can access the value in the function while
calling it from vb 6)
Write a log file as suggested, or use OutputDebugString with the DebugView
program fromwww.sysinternals.com
--
Gabriel Genellina
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt Smith |
last post by:
Hi, all.
Just a quick question, when setting a COM process to read a value from
a pre-defined register index, I think, I have to change the variable
that the value will be returned to (as I have...
|
by: Dave |
last post by:
I have been trying an example from the Python Programming on Win32 book on the lastest versions of python (2.3.3) and win32all (build 163). I create the COM object and try to call it from VB but i...
|
by: Annie |
last post by:
I am trying to call a COM object which expects a variant datatype to
be passed in to the COM API object. However, I get "<COMObject
<unknown>>" and the program fails.
Below is my code in Python,...
|
by: Raoul |
last post by:
I wrote a COM server object in C++ a few months ago. I can use it from
Visual Basic, Visual C++, S-Plus and a number of other scripting
environments.
What I can't do is use it with my FAVOURITE...
|
by: mb3242 |
last post by:
Hello, I'm trying to use win32com to call a method in a COM object.
I'm having a problem with Python choosing the wrong type when wrapping
up lists into VARIANTs.
The function I'm trying to call...
|
by: Ken Layton |
last post by:
Attempting to pass a VBScript Array of Bytes to a C# Managed COM object has
resulted in some very undesirable and strange behavior. When definining a
method in my C# COM class as "void Write(byte...
|
by: Mark |
last post by:
Hi
From what I understand, you can pass arrays from classic ASP to .NET using
interop, but you have to change the type of the.NET parameter to object.
This seems to be because classic ASP passes...
|
by: dwinson |
last post by:
I am writing an add-in in C# for a server written in VB6.
In order for my add-in to work I need to implement this method:
MyMethod(string inputData)
.... so my C# code looks like this:
...
|
by: Rafe |
last post by:
Forgive me if I mangle any terminology here, but please correct me if
I do...
I have an object which acts exactly like a string as long as I stay in
Python land. However, I am using the object...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |