import statement is case sensitive

David Bolen db3l at
Sat Feb 24 01:34:25 CET 2001

costas at (Costas Menico) writes:

> 1) I can get PythonWin import to be case-insensitive but only if I do
> an os.environ["PYTHONCASEOK"]="1" before the import (but after I
> import os in the correct case :)

Or just set PYTHONCASEOK in the environment from which you start
Pythonwin or your scripts.

> 2) I tried setting it at the DOS prompt (SET PYTHONCASEOK=1) but
> python.exe seems to ignore it.

That should work - are you positive you're running python under that
same environment (e.g., you can't set that variable in a DOS prompt,
then exit that shell, and restart another to run Python in).

> 3) You can set View/Folder Options/View in Windows Explorer to allow
> all upper case filenames. But it really looks screwed up since many
> directories are in upper case. Very difficult to read.

And that's actually what your filesystem contents contains - ugly
isn't it?  The whole mess with the "pretty" settings in stuff like
Explorer is just to hide how badly some of the older filesystem types
deal (or don't deal) with case.

> 4) python -h   scrolls off the screen and there is no way to either
> redirect the output nor pipe it to MORE.EXE.I had to find the help in
> the book.

This is a little tricky - the output goes to stderr rather than stdout
(the error output stream) which isn't normally included in your pipe.
You could fix this by routing stderr to stdout, as in:

    python -h 2>&1 | more

Of course, the output isn't all that big, so you only miss a few
lines.  Using something like "mode 80,30" to make a bigger window
would work as well.

Then again, the help doesn't mention PYTHONCASEOK so it's not going to
be too much help in that regard :-)

> The original problem i was faced had to do with mxODBC. He imports
> from ODBC (upper case) directories in his sample code. I know I can
> change his code but I this is the stuff that comes back to bite.. 

But uppercase is correct - so why would you want to change the imports
to lowercase (I'm guessing that's what you are trying?)

Note that one source of confusion is the existence of an "odbc.pyd"
module in the win32all distributions.  You should delete or rename
that if you're going to be using mxODBC or you might not get the
module you want (or might get a complaint about "import ODBC" if
Python finds the win32all "odbc" module first).

-- David
 \               David Bolen            \   E-mail: db3l at  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \

More information about the Python-list mailing list