G
gregturn
Hi
Why this doesn't work:
def go():
for line in open("bobo.txt", "r"):
print line
go()
python FileReader.py: everything ok
jython FileReader.py:
Traceback (innermost last):
File "FileReader.py", line 6
File "FileReader.py", line 3
AttributeError: __getitem__
Files aren't lists and thus don't have the functions for iteration.
Try:
def go():
for line in open("bobo.txt", "r").readlines():
print line
go()