Improved struct module

Eric Jacobs x at x.x
Wed Oct 13 17:59:17 EDT 1999


Fredrik Lundh wrote:
>
> > Haven't heard of this, but don't people use SWIG anymore <0.7 wink>?
> 
> real programmers don't ;-)
> 
>     http://www.nightmare.com/~rushing/dynwin/index.html
> 
> (uses Sam's calldll and npstruct modules to access every
> little corner of windows without any custom win32 inter-
> faces)

When I need to use calldll for windows functions I use this little
one-liner:

Prototype = lambda l,n,i,o:
            lambda a,l=l,n=calldll.get_proc_address(l,n),i=i,o=o: 
	    calldll.call_foreign_function(n,i,o,a)

Then:

Kernel32 = calldll.load_library("Kernel32.dll")

CreateFile = Prototype(Kernel32, "CreateFileA", "siiiiii", "i")

Works well for quick hacks. The only annoying thing is it
actually creates a function that takes a tuple rather than the
actual arguments, so you have to remember to double the
parentheses.

In order to avoid that you'd have to use the non-existant
syntax:

	lambda *a, l=l, ...

Oh well, so much for the default argument hack, huh?




More information about the Python-list mailing list