dumb newbie questions

Steve Holden sholden at holdenweb.com
Thu Jan 17 16:52:32 EST 2002


----- Original Message -----
From: "Jonathan Gardner" <jgardn at alumni.washington.edu>
To: "Steve Holden" <sholden at holdenweb.com>; <python-list at python.org>
Sent: Thursday, January 17, 2002 4:46 PM
Subject: Re: dumb newbie questions


> > Hope this was slow enough. You seem to have grasped most of the
essentials
> > - I guessed you had at least some experience in another programming
> > language, so maybe you're doingt better than you think. Your output
code
> > looks OK. See how it goes with these changes.
> >
>
> One little thing I want to add....
>
> When you are writing a serious program, like, let's say a program that
> calculates the inverse of square matrices, you'll want to avoid user
input
> like the plague. Why? If you have to keep typing, you get angry
because you
> make minor mistakes, and it is also tedious. Plus, when you are
entering a
> matrix, you can potentially be entering hundreds of values. When is
the last
> time you have never made a mistake entering hundreds of values?
>
> What you may want to do is accept a file for simplicities sake. The
file can
> be in the format of:
>
> 1.1 1.1 1.1 1.1
> 1.1 1.1 1.1 1.1
> 1.1 1.1 1.1 1.1
> 1.1 1.1 1.1 1.1
>
> It should be easy enough to edit the file to your liking, and use it
over and
> over again. And you can keep several files lying around as test cases
to see
> if your code is functioning properly.
>
> You can take your shell (your not using Windows, are you?) and dump
the file
> into your program as stdin.
>
> $ cat matrix.txt | python inverse.py
>
or, to avoid creating an unnecessary process,

python inverse.py < matrix.txt

This will even work on most versions of Windows, though not if you omit
the "python" command and expect the command interpreter to deduce the
required processor. That's a game you are safest only playing in Unix.

[ ... other sound advice ...]
>
be-kind-to-your-shell-and-it-will-be-kind-to-you-ly y'rs  - steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/








More information about the Python-list mailing list