This is a piece of my code…
def contactMaster(data="",url= str(chosenMaster)+"todolist"):
print "url: "+url
It prints only “todolist” instead of “http://www.mysite.com/blah/1234/todolist”
Why isn’t it working??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Default arguments are evaluated when the function is defined not when it is executed. So if
chosenMasteris empty when Python definescontactMaster, it will print onlytodolist.You need to move
str(chosenMaster)into the function.See Default Argument Values in the Python Tutorial for more info. The example there is: