0

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='me@example.com')
What is your work email?
the default is me@example.com...press 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

codyc4321
  • 9,014
  • 22
  • 92
  • 165
  • Possible duplicate of [Python unexpected EOF while parsing](http://stackoverflow.com/questions/5074225/python-unexpected-eof-while-parsing) – l'L'l Feb 12 '16 at 17:16

1 Answers1

2

The problem is

answer = input(text)

In python 2.7 you want to use raw_input(...) rather than input(...)

Chad S.
  • 6,252
  • 15
  • 25