Python bindings tutorial

Terry Reedy tjreedy at
Wed Mar 17 21:12:11 CET 2010

On 3/17/2010 8:18 AM, Stefan Behnel wrote:
> Dave Angel, 17.03.2010 12:14:
>> Stefan Behnel wrote:
>>> I think the point here is that executable binaries are not supposed to
>>> be used as libraries. Libraries are. That's the difference between a
>>> DLL and an executable in the first place. To run an executable,
>>> execute it. The subprocess module is the tool of choice here. To use a
>>> DLL, link against it.
>> There's no real reason parts of an exe cannot be exported, same as a
>> dll. They are in fact the same structure. And in fact many other files
>> in the Windows environment are also the same structure, from fonts to
>> ocx's
> So, because you can, you'd also try to link against fonts then, I guess?
> I hope you notice that what you and me said isn't contradictory. But
> there's a reason why there are libraries and executables, and there's no
> reason you *should* export anything from an executable - that's what
> libraries are there for. That's my point.

To put it another way, if an executable has functions that could/should 
be available as 'library' functions, then they can/should be put in a 
separate library file for use as such and called from a smaller .exe.

This is what python itself does. For 3.1 on winxp, python.exe is only 26 
Kb, while python31.dll, with all the builtin functions and classes, (in 
windows/system32) is 2072 KB.
> Besides, nothing guarantees that it's safe to call stuff that an
> executable exports. The executable may well require some setup code that
> it only executes when it is properly started.

Terry Jan Reedy

More information about the Python-list mailing list