Issue
in my setup scripts a function I've used for a year now is suddenly broken. I cut and pasted it into ipython to see if it was the file, but I'm getting a general syntax error where not only is no error visible, but the function that used to work hasn't changed
In [8]: def gather(msg=None, default=None):
...: while True:
...: text = msg + '\n'
...: if default:
...: text += "the default is {default}...press enter to accept\n".format(default=default)
...: answer = input(text)
...: return answer or default
...: answer = input(text)
...: if not answer:
...: continue
...: return answer
...:
In [9]: EMAIL = gather(msg='What is your work email?', default='[email protected]')
What is your work email?
the default is [email protected] enter to accept
File "<string>", line unknown
^
SyntaxError: unexpected EOF while parsing
Here is the func
def gather(msg=None, default=None):
while True:
text = msg + '\n'
if default:
text += "the default is {default}...press enter to accept\n".format(default=default)
answer = input(text)
return answer or default
answer = input(text)
if not answer:
continue
return answer
I was using python 2, same as before. Why did this break? Thank you
Solution
The problem is
answer = input(text)
In python 2.7 you want to use raw_input(...)
rather than input(...)
Answered By - Chad S.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.