[python-win32] passing c structure into python function
Aahz
aahz at pythoncraft.com
Tue Jan 12 20:41:34 CET 2010
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?
BTW, I think that in example code it's a Good Idea to follow PEP8...
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur." --Red Adair
More information about the python-win32
mailing list