[python-win32] passing c structure into python function
Tim Roberts
timr at probo.com
Tue Jan 12 23:07:32 CET 2010
Aahz wrote:
> On Tue, Jan 12, 2010, Tim Roberts wrote:
>
>> I would pass the struct as a string of 14 bytes, then use
>> emp_name, emp_ID = struct.unpack( '=10cI', incoming )
>>
>> class employee:
>> def __init__( self, name, id ):
>> self.name = name
>> self.id = id
>> def to_file( self, f ):
>> f.write( struct,pack( '=10cI', self.name, self.id )
>> def from_string( self, s ):
>> self.name, self.id = struct.unpack( '=10cI', s )
>>
>
> Why are you using the asymmetric "to_file" and "from_string" methods?
> Just for examples?
>
Yes. That nagged me when I wrote it, and I decided to leave it as an
exercise for the reader...
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list