Win98 PySol problem

Bill Melcher wpmelcher at snet.net
Mon Nov 26 09:50:02 EST 2001


"Kragen Sitaker" <kragen at canonical.org> wrote in message
news:83r8qmtgu9.fsf at panacea.canonical.org...
> "Bill Melcher" <wpmelcher at snet.net> writes:
>
> I think you should use the console window instead of the Run window.
> You can get a console window by typing 'cmd' or 'command' in the Run
> window, depending on your version of Windows.

Yes, this is a good idea -- actually I have a Windows 'shortcut' that will
crank up a MS DOS window.  I used this technique to capture the Python
usage:

C:\>python -h>python.txt

usage: O:PYTHON21\PYTHON.EXE [option] ... [-c cmd | file | -] [arg] ...

options and arguments (and coresponding environment variables):
-d     : debug output from parcer (also PYTHONDEBUG=x)
-i     : inspect interactively after running script, (also PYTHONINSPECT=x)
         and force prompts, even if stdin does not appear to be a terminal
-O     : optomize generated bytecode (a tad; also PYTHONOPTOMIZE=x)
-OO    : remove doc-strings in addition to the -O optomizations
-S     : don't imply 'import site' on initialization
-t     : issue warnings about inconsistent tab usage (-tt: issue errors)
-u     : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
-U     : unicode litterals: treats '...' literals like u'...'
-v     : verbose (trace import statements) (also PYTHONVERBOSE=x)
-x     : skip first line of source, allowing use of non-Unix forms of #! cmd
-h     : print this help message and exit
-V     : print the Python version number and exit
-W arg : warning control (arg is action:message:category:module:lineno)
-c cmd : program passed in as string (terminates option list)
file   : program read from script file
-      : program read from stdin (default; interactive mode if a tty)
arg... : arguments passed to program in sys.argv[1:]

Other environment variables:

PYTHONSTARTUP: file executed on interactive startup (no default)
PYTHONPATH   : ';'-separated list of directories prefixed to the
               default module search path.  The result is sys.path.
PYTHONHOME   : alternate <prefix> directory (or <prefix>;<exec_prefix>.
PYTHONCASEOK : ignore case in 'import' statements (Windows).

This stuff looks better in a mono-type font.

Unfortunately, Python seems to mess up the DOS redirection so that in the
command line above, the '>python.txt' fragment creates the .txt file in C:\
but the output is not redirected to that file. The ability to specify "|
more" is also crippled by python.  I caught the console output by using the
Pause key and typing what I saw into an editor.

This 'failure' to allow redirection is the reason why I have problems
capturing the stdout and errout using redirection.  If I use the Pause key
often enough, maybe I can see at least some of the error messages. :-)

>
> Well, running it in a console window will save the last
> scroll-buffer-full.  You can set your scrollback buffer size (on
> better versions of Windows) with some Properties dialog --- I can't
> remember where.

I'll see if I can track this down.

>
> There's little bits of python you could do to save the messages to a
> file.  I think you can say:
> import sys
> sys.stdout = file.open("output", w)
> sys.stderr = sys.stdout
> execfile "Q:\\pysol-4.2\\src\\pysol.py"

I would presume that I should run this in pythonwin or ppm or idle.  I will
give it a shot.

>
> python foo.py will run foo.py by compiling it into bytecode (P-code)
> and then running the bytecode; if possible, Python will also save the
> bytecode in foo.pyc.  In the future, python will check to see if
> foo.pyc is newer than foo.py, and if so, it will run the bytecode from
> the file instead of recompiling foo.py.

I had come to that exact conclusion and had planned to do an experiment,
i.e., re-install the original source files or delete the .pyc files and run
the sucker again.

>
> I use Unix, and I type 'man python', which won't work on Win98.
> Section 2 of the Python Tutorial has some of what you want; more of it
> is in section 6.1.

The Windows version of Python contains help files that contain the
documentation and I have picked up a few other goodies in various formats.

I just did a quick look at these sections of the tutorial - I think I'll
print out the sections and study them.
>
> > Another topic is a file called ".gdbinit" which contains:
> >
> > file python
> > set args -u -t pysol.py
> >
> > What the heck is this?
>
> Sounds like an initialization file for the GNU debugger, to set it up
> to run your Python command under the debugger.  Dunno why Python
> recorded this.  Mine sure doesn't.

Sorry, I confused you.  This is a file in the PySol source.  As you can
easily see, I am still having problems separating out the Python issues from
the PySol issues and the MS DOS/Win issues! The whole situation is made more
confusing because I have very little Unix understanding while you guys tend
to be weak on Win98.

In essense, I need to figure out who's doing what to whom, then burrow down
into which ever product is giving me grief --

>
> Glad you're not giving up!

Not yet!

--
Cheers, Bill
TANSTAAFL!





More information about the Python-list mailing list