Jython
gregturn at mindspring.com
gregturn at mindspring.com
Sat Feb 3 11:20:48 EST 2007
On Feb 3, 11:21 am, Boris Ozegovic <silovana.vjever... at com.gmail>
wrote:
> 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__
>
> --
> "A mi smo stranci u vlastitoj zemlji zbog ljudskog sljama, lipa nasa
> silovana"
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()
More information about the Python-list
mailing list