Python Unit Tests

Steven D'Aprano steve at pearwood.info
Sun Sep 29 22:55:19 EDT 2013


On Sun, 29 Sep 2013 18:46:30 -0700, melwin9 wrote:

> Hi Terry & Dave,
> 
> Thanks for the suggestions. I am running Python 2.7 and when I tried the
> code above it said def main(target) <- invalid syntax. 


Did you fix the invalid syntax? Until you fix it, you're blocked.

As a programmer, it is completely normal to occasionally make a typo or 
other trivial mistake that leads to invalid syntax. It's not worth 
mentioning. You just fix it and move on.

It's a bit like being a cook. The recipe says, "add one tablespoon of 
sugar", and you say "well I tried, but the spoon bangs on the lid of the 
jar." The solution is to take the lid off first. The recipe doesn't 
mention this, just like the recipe doesn't say "take the spoon out of the 
cutlery drawer". You just do it.

If you don't understand the syntax error you got, firstly try to compare 
the bad syntax

def main(target)
    blah blah blah


with working functions that don't give syntax errors

def function(arg):
    blah blah blah


Can you spot the difference? Hint: the syntax error will show an arrow ^ 
pointing at the spot where it notices a problem. Can you fix the problem? 
If so, great, move on! If not, ask for help, but remember to COPY AND 
PASTE the entire traceback, starting with the line

Traceback (most recent call last)

all the way to the end of the error message.



-- 
Steven



More information about the Python-list mailing list