[python-win32] GetDiskFreeSpaceEx

Tim Golden mail at timgolden.me.uk
Tue Jul 13 16:41:10 CEST 2010


[cc-ing back to the list so other helpers and future Seekers
of the Truth can see what happened next...]

On 13/07/2010 15:27, Vittorio Zuccala' wrote:
> 2010/7/13 Tim Golden<mail at timgolden.me.uk>
>
>> If you haven't already, get hold of the pywin32 extensions to Python:
>>
>>   https://sourceforge.net/projects/pywin32/
>>
>> They contain a *lot* of the Win32 API that you'll need. Including the one
>> you're after:
>>
>
>
> Ok, i've downloaded and installed it.

> Wonderful!
> This page is very useful
> http://timgolden.me.uk/pywin32-docs/win32_modules.html

I can only take a small amount of credit there. All the work
producing the pywin32 package was done by Mark Hammond, Roger
Upole and others. My small contribution here is to take the
.chm it ships with and to unpack it into individual HTML
pages. Glad it's helpful.

> So.. let me understand better.
> ctypes is a module which let the programmer to interface with system
> libraries.
> win32api is a sort of extension of ctypes for win32 systems.
> Are these two sentences correct?
>


The first certainly is. The second... not quite. Python has a C API:

   http://docs.python.org/c-api/

which can be used to wrap external systems / libraries etc. and expose
them as Python objects. This been in existence for as long as Python
itself, and is used by pywin32 and many other projects to offer Python
the ability to interface with toolkits, libraries and so on.

ctypes was a later addition, courtesy of the ingenious Thomas Heller.
It lets you interface with shared libraries directly from Python without
having to write C code. This has several advantages: (1) you don't have
to write anything externally and link it in; (2) you're insulated to some
extent from compiler / type library incompatibilities; (3) it's *really*
easy to use and drops things straight into Python. And several 
disadvantages:
(1) you sometimes have to work quite hard to translate C-level examples into
ctypes Python; (2) you can crash Python hard -- something it's very 
difficult
to do with the language alone.

TJG


More information about the python-win32 mailing list