Connecting Tech Pros Worldwide Help | Site Map

Help needed on COM issue

Mike Howard
Guest
 
Posts: n/a
#1: Apr 12 '06
I'm doing some conversion of vb code to python code and I have a
problem with a COM object

Specifically in VB I can do
Set oR = oA.Action
debug.print oR.Item(1,2)
[returns say "1"]
oR.Item(1,2)="4"
debug.print oR
[returns "4"]

In Python I need to do ..

oR=oA.Action()
print oR.Item(1,2)[0]
[returns say "1"]
oR.Update
[saves the record with the new item]

But when I ty to update the value

oR.Item(1,2)[0]="4"

I get a TypeError : object doesn't support item assignment.

I presume this is because Python is returning oR as a tupe - hence the
need to refer to Item(1,2)[0] - but I can't figure out the equivalent
method to update the value I need.

Any help appreciated.

Mike Howard
Guest
 
Posts: n/a
#2: Apr 12 '06

re: Help needed on COM issue


Should read ...
I'm doing some conversion of vb code to python code and I have a
problem with a COM object

Specifically in VB I can do
Set oR = oA.Action
debug.print oR.Item(1,2)
[returns say "1"]
oR.Item(1,2)="4"
debug.print oR
[returns "4"]
oR.Update
[saves the record with the new item]

In Python I need to do ..

oR=oA.Action()
print oR.Item(1,2)[0]
[returns say "1"]

But when I ty to update the value

oR.Item(1,2)[0]="4"

I get a TypeError : object doesn't support item assignment.

I presume this is because Python is returning oR as a tupe - hence the
need to refer to Item(1,2)[0] - but I can't figure out the equivalent
method to update the value I need.

Any help appreciated.

Philippe Martin
Guest
 
Posts: n/a
#3: Apr 12 '06

re: Help needed on COM issue


Hi,

First I'd check if the type is indeed tuple.

How about converting the tuple to a list, modifying the list, then making it
a tuple again ?

Philippe



Mike Howard wrote:
[color=blue]
> Should read ...
> I'm doing some conversion of vb code to python code and I have a
> problem with a COM object
>
> Specifically in VB I can do
> Set oR = oA.Action
> debug.print oR.Item(1,2)
> [returns say "1"]
> oR.Item(1,2)="4"
> debug.print oR
> [returns "4"]
> oR.Update
> [saves the record with the new item]
>
> In Python I need to do ..
>
> oR=oA.Action()
> print oR.Item(1,2)[0]
> [returns say "1"]
>
> But when I ty to update the value
>
> oR.Item(1,2)[0]="4"
>
> I get a TypeError : object doesn't support item assignment.
>
> I presume this is because Python is returning oR as a tupe - hence the
> need to refer to Item(1,2)[0] - but I can't figure out the equivalent
> method to update the value I need.
>
> Any help appreciated.[/color]

Closed Thread