So far I have found a way to yield the name, string, and extra string. It works for the second one but does not work for the first one? it\'s so weird because the formats a
The actual problem is, you are not split
ing before yielding. So change the code like this
if line.startswith('@'):
if name:
body, extra = body.split('+',1)
yield name, body, extra
body = ''
name = line
else:
body = body + line
body, extra = body.split('+',1)
yield name, body, extra
Also, the following if
condition has no effect in the output of the program
if line == '+':
pass
So, I removed it in the above code.