[Tutor] Windows, Python and me

Tim Peters tim.one@home.com
Wed, 15 Aug 2001 05:27:06 -0400


[alan.gauld@bt.com]
> ...
> [Aside: I never understood why MS didn't have a registry
> key that got loaded from Autoexec instead of relying on
> PATH... Or maybe they do, in which case what is it?
> And shouldn't new apps set that instead? ]

An app can set a PATH that *it* wants to use via fiddling the registry, but
that doesn't help you find the app to begin with.  In MS's current view,
autoexec.bat shouldn't exist (e.g., you can't get an app certified for
Windows if it touches autoexec.bat, and a little-known fact is that Win9X
runs fine even if you don't have *any* autoexec.bat); and that command lines
are an anachronism.  So long as you launch every program by clicking on
something, that "something" is supoosed to have the path to the executable
more-or-less hardwired into it, invisible to users.

>> We do set file associations, although I don't find them
>> useful for Python on Win9x.

> Really?

Yes, but I'm old and am much more comfortable in a DOS box <wink>.

> I couldn't live without them. Its how I launch nearly
> all my python scripts - just double click the file oir type
> the name in Start|Run...

That's why I keep teaching our Windows installer how to set up the darned
asssociations -- and I test that once per release <wink>.

...

>> The former (Start|Run) has to do with a different registry
>> setting, neither with PATH nor with file associations.

> Now that I didn't know! Which one?

The same one that gets looked up by magic if you do

    start python

from a DOS prompt; it's under key

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
     App Paths\Python.exe

The default value of that key is the path to the executable (and that's how
Start|Run finds it).  Peek (don't poke!) around in that part of the registry
and you'll see other possibilities; for example, the way for an app to
register its own PATH setting is to create a value named "Path" under that
key, with string data giving the PATH setting it wants.

> Is that set by the installer coz I must admit thats how I
> usually get a Python prompt rather than start a DOS box
> per se. Maybe thats why I assumed PATH was being set?

Yes, I go through a lot of pain to set that up <wink>.  Unfortunately, MS
seemed to have the *start* of a good idea here but didn't follow through.
>From a random DOS prompt, you can't generally get away with doing

    python whatever.py

(if python isn't on your path), but you *can* get away with

    start python whatever.py

(again thanks to the registry key above).  Even better would be if you could
get away with

    whatever.py

or just plain

    whatever

(and in NT and 2000, you can get close to the latter via setting the PATHEXT
envar apprporiately).

>> Windows is very consistent <wink>.

> Consistently frustrating that's for sure :-)

Yup.  The more you learn about it, the more depressing it gets.

> As a recent email dialog with Michael showed I am now in the
> pitiable state of being sufficiently immersed in Windoze
> to have forgotten much of my Unix knowledge but not enough
> into Windows to be an expert there - yet?

I'm not sure it's worth trying.  *I'm* no Windows expert -- I'm not a
Windows developer, I'm just a developer who, for business reasons, got stuck
using Windows in '94.  As an end-user, I actually like it a lot; but as a
developer, it drives me nuts.  A co-worker once explained it in terms that
still ring true:  Windows developement is like wading through a boundless
ocean that's a quarter of an inch deep.  That is, it's endless but very
shallow -- you can wait for years to get the "aha!" kind of unifying
experience you eventually get on, say, Unix, but it never comes.  Instead
it's the world's largest (outside of IBM, I guess <wink>) random collection
of endlessly layered backward compatibility hacks.  For anything you want to
do, you can find ten ways in the docs that *might* be appropriate, but you
find out the hard way nine of them don't work, and eventually you find the
one way that does work -- but you never understand why.

I hope Windows XP catches on big, so that we can finally have some hope of
leaving behind the worst of the DOS/Win3.1/Win9x legacy.  Technologies like
COM are really mondo cool; but it's hard to get to the point where you can
appreciate them when you have to reboot the machine once an hour.

ventingly y'rs  - tim