Holy macaroni I stink at this

Hutchins, Mike mhutchins at amr-corp.com
Tue Feb 11 15:51:58 EST 2003


>Hey, welcome to the club!  I would encourage you to keep the spirit
that led you to solve the problem at hand.  Sounds to me like you just
need  >refinement around the edges.  For that, I'd suggest:
>
>1) Consider writing tests before you code.  I've never regretted the
few times I've successfully done this.  Look up the unittest module.  
>Mark Pilgrim's Dive Into Python has a good chapter on unit testing.
>
>2) Identify the runtime errors you expect and trap them with try/except
where appropriate.
>
>For instance, suppose you're writing a program that takes a filename
parameter; you can display a usage message if the parameter is missing:
>
>import sys
>import os
>
>usage = '%s filename\n' % os.path.basename(sys.argv[0])
>	try:
>	    filename = sys.argv[1]
>	except IndexError:
>	    sys.stderr.write(usage)
>	    sys.exit(1)
>
>// m

Thank you much!

I will see if I can grab that book on my way home from work.

I am now going to commence looking at unittest and see what I can cull
from that.

I shall not let my lack of skills (at this point) deter me from
completing this and learning all I can.
Thanks again. (I am sure I will be back for more questions)

Mike





More information about the Python-list mailing list