How to create a file on users XP desktop

Tim Golden mail at timgolden.me.uk
Mon Oct 8 11:11:25 EDT 2007


kyosohma at gmail.com wrote:
> On Oct 8, 9:19 am, goldtech <goldt... at worldpost.com> wrote:
>>> from win32com.shell import shell, shellcon
>>> desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
>>> </code>
>> Tim,
>>
>> How did you learn Win32com?
>>
>> Other than the O'Reilly book, I've never found a lot of
>> documentation.
>>
>> Trying to browse COM in PythonWin is tough - there's tons of stuff in
>> there. I've never been able to find the Win32com classes, methods,
>> usage examples when I browse COM in PythonWin.
>>
>> For example where is, shell.SHGetFolderPath and shellcon.CSIDL_DESKTOP
>> officially documented?
>>
>> Did you learn from using Visual C++ or VB? How did you learn this
>> stuff?
>>
>> Thanks,
>> Lee G.
> 
> Pretty much the only place to learn stuff that's not in the PyWin32
> docs is on one of the MSDN sites. Yes, that can suck. Here's the
> general page: http://msdn2.microsoft.com/en-us/default.aspx
> 
> You can google for them too to get direct links to the MSDN page.
> 
> The ActiveState Python (AKA ActivePython) has an IDE that allows you
> to browse the COM module. It also has a help file that allows you to
> browse the PyWin32 docs locally. I think you can download that without
> downloading ActivePython.
> 
> Mike

FWIW, the pywin32 distribution itself also comes with a local
.chm file. But aside from that, there have been several abortive
attempts -- including by Mike & myself! -- to get some kind of
online help going for pywin32, but nothing's really gained traction,
and we've all got more interesting things to be doing...

One point to bear in mind that, more or less, the pywin32 stuff
just wraps the MS API really closely, mostly doing just enough
of the messy plumbing to present the API "objects" as Python
objects. That's to say: find out how to do it from a C++ or VB
or Delphi tutorial and translating into Python often isn't hard.

As it happens I've been using Windows APIs for a few years,
so I have a bit of a head start. But I've answered quite
a few questions on python-win32 by putting the subject line
into Google, picking a likely-looking response and translating
it into Python.

In this case ("How to create a file on users XP desktop") the
question was too broad and tended to throw up user-oriented
answers. I tried a few permutations, including limiting the
search to msdn.microsoft.com, none of which showed much on the
first couple of pages. A search of the pywin32.chm files does
point in the right direction, but the fact is that the shell
functionality exposed by Windows which does this kind of
stuff is non-intuitive.

While I think everyone agrees that the Windows side of Python
could benefit from more and better docs, the general answer to:
How do I do X in Python under Windows? is: How do I X under Windows?

TJG



More information about the Python-list mailing list