[Tutor] oops!

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri, 4 Jan 2002 22:40:05 -0800 (PST)


On Sat, 5 Jan 2002, Kirk D Bailey wrote:

> Def writependings(omitme, list):        # write back the pendings,
>         f6=open('./lists/pending','w')  # OMITTING one item.   
>         for item in list: 
>                 if item != omitme:
>                         f6.write(item)+CRLF
>         f6.close()
> 
> ns# ./TLlistmaster.py < testfile
>   File "./TLlistmaster.py", line 201
>     Def writependings(omitme, list):      # write back the pendings,
>                     ^
> SyntaxError: invalid syntax
> ns#_
> 
> COULD IT BE this function name is simply too long?


Function names can be pretty long:

###
>>> def salutatiousGreeting(): print "salutations!"
... 
>>> salutatiousGreeting()
salutations!
###

What you're running into is the case sensitivity of Python keywords:

###
>>> Def hello():
  File "<string>", line 1
    Def hello():
            ^
SyntaxError: invalid syntax
###

The error's pointing at the "hello", but it's really the 'Def' that's
confusing Python.  Lowercase the 'Def', and you should be ok.