Our lecturer gave us some code to help us with an assignment and when I try to run it I get a syntax error. I haven't touched the code at all and it's meant to run without us having to change anything. This is half the code that we were given:
class Flusher(MessageProc):
def main(self):
super().main()
print('before start message')
self.receive(
Message(
'start',
action=self.flush))
print('after start message')
self.receive(
Message(
ANY,
action=lambda data:print('The first thing in the queue after the flush is', data)))
def flush(self, *args):
self.receive(
Message(
ANY,
action=self.flush), # recursively call the flush method
TimeOut(
0,
action=lambda: None)) # when no more messages return
And the line that throws the exception is:
action=lambda data:print('The first thing in the queue after the flush is', data)
This is my first time using Python so please can someone explain what's wrong and what I should do to fix it.
EDIT: The error trace is:
File "./demo_timeout.py", line 18
action=lambda data:print('The first thing in the queue after the flush is' + data)))
^
SyntaxError: invalid syntax