D
David Stockwell
Hi,
Section 9.10 of the tutorial discusses the yield keyword. When I tried
using it I get the following SyntaxError.
What does this error mean? Does it mean we can't use yield in our code? Is
yield a form of a 'return' ??
class9.py:71: Warning: 'yield' will become a reserved keyword in the future
File "class9.py", line 71
yield data[index]
^
SyntaxError: invalid syntax
Here is the code from the tutorial: (i modifed the print statement)
def reverse(data):
for index in range(len(data)-1, -1, -1):
yield data[index]
for char in reverse('golf'):
print char,
Thanks,
David
_________________________________________________________________
Express yourself with the new version of MSN Messenger! Download today -
it's FREE! http://messenger.msn.com/go/onm00200471ave/direct/01/
Section 9.10 of the tutorial discusses the yield keyword. When I tried
using it I get the following SyntaxError.
What does this error mean? Does it mean we can't use yield in our code? Is
yield a form of a 'return' ??
class9.py:71: Warning: 'yield' will become a reserved keyword in the future
File "class9.py", line 71
yield data[index]
^
SyntaxError: invalid syntax
Here is the code from the tutorial: (i modifed the print statement)
def reverse(data):
for index in range(len(data)-1, -1, -1):
yield data[index]
for char in reverse('golf'):
print char,
Thanks,
David
_________________________________________________________________
Express yourself with the new version of MSN Messenger! Download today -
it's FREE! http://messenger.msn.com/go/onm00200471ave/direct/01/