I'm trying to learn Python online, using DiveIntoPython.org. The first example program I have tried is this:
I'm running this in an OS X Terminal and I'm getting the following error message:
Can anyone explain what the problem is? I did a cut & paste from the pdf, so it should work, according to the book. I don't see any syntax error.
Code:
def buildConnectionString(params):
"""Build a connection string from a dictionary
Returns string.
"""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
if __name__ == "__main__":
myParams = {"server":"mpilgrim", \
"database":"master", \
"uid":"sa", \
"pwd":"secret"
}
print buildConnectionString(myParams)
I'm running this in an OS X Terminal and I'm getting the following error message:
Code:
/Users/peterv/bin/test1.py: [b][COLOR=red]line 1: syntax error near unexpected token `('[/color][/b]
/Users/peterv/bin/test1.py: [b][COLOR=red]line 1: `def buildConnectionString(params):'
[/color][/b]
Can anyone explain what the problem is? I did a cut & paste from the pdf, so it should work, according to the book. I don't see any syntax error.