[python-win32] How to add a record to a record list??
Jeff Shannon
jeff at ccvcorp.com
Mon Aug 4 10:56:28 EDT 2003
kbond wrote:
> # The method Value is actually a property, but must be used as
> a method to correctly pass the arguments
> def Value(self, HeaderName=defaultNamedNotOptArg):
> """Retrieves, sets or adds a value to the object.
> Specified by header name."""
> return self._ApplyTypes_(0, 2, (12, 10), ((8, 1),),
> 'Value', None,HeaderName)
>
> >>> recList.Value["joe","FirstName"]
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> TypeError: unsubscriptable object
> >>> recList.Value["FirstName", "joe"]
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> TypeError: unsubscriptable object
> >>> recList.Value["FirstName", 0]= "joe"
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> TypeError: object does not support item assignment
I'm not sure what the API for this recordlist is, so it's hard for me to
say just what the appropriate syntax is here, but here's a few ideas to
(hopefully) help you figure it out.
These properties all say they must be used as a method. That means
you'll need to use parentheses rather than square brackets. Also, as
you've seen, you cannot assign to the result of a method call, i.e.
'recList.Value(...) = name' is an error. In order to provide the value
that you want to set the field to, you'll have to include that as a
parameter in the method call -- that is, "joe" needs to be inside the
parentheses. Thus, I believe that you'll need to use something along
the lines of one of these:
reclist.Value("FirstName", "joe")
reclist.Value("FirstName", 0, "joe")
Hope that helps...
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-win32
mailing list