Python ctypes / pywin32 [was: GUIs - A Modest Proposal]

lkcl luke.leighton at gmail.com
Sat Jun 12 11:57:03 EDT 2010


On Jun 10, 6:26 pm, "Martin v. Loewis" <mar... at v.loewis.de> wrote:

> >> or PyGui would need to be implemented in terms of ctypes (which then
> >> would prevent its inclusion, because there is a policy that ctypes
> >> must not be used in the standard library).
>
> > Is there? I wasn't aware of that. What's the reason?
>
> ctypes is inherently unsafe.

 that's ok.  only the sanest and most careful of programmers are going
to use it.  and all they're going to do is crash their application if
they get it wrong.  or, on an OS which is _known_ to be so unstable
that it will fall over with the slightest provocation, crash the OS
and require a press of that little button which was moved to the front
_just_ to deal with that OS's instability, once again.

 just because a library has a means for programmers to shoot
themselves in the foot doesn't mean that the programming language
should come with kevlar-reinforced bullet-proof vests.


> It must be possible to remove it
> from a Python installation,

 as long as that's not an official policy statement that ctypes will,
at some point in the future, be removed from python, i'm happy.

 the last thing i want to have to do is to have to include and
maintain, as part of the pyjamas download, a complex python-ctypes
library in order to get at the win32 functions "CreateWindowEx"; the
second last thing i want to have to do is rewrite pyjd's MSHTML port;
the third last thing i want to have to do is state that a 2nd and
_much_ larger library dependency/download is required: pywin32.

 one of the really nice things about having chosen ctypes and a copy
of henk punkt's windows.py file is that the only dependency required
is one single 350k download: python-ctypes.  last time i looked,
pywin32 was a whopping 6mb, and there's _nothing_ in pywin32 that pyjd
actually needs.

 i deliberately bypassed python-win32com for exactly the same reason:
it turns out that direct ctypes access to Variant and all other OLE /
COM types is perfectly sufficient.

 removal of ctypes would be a big, big mistake.  i trust that i have
misinterpreted the implication of what you're saying, martin.

 l.



More information about the Python-list mailing list