On Feb 3, 11:21 am, Boris Ozegovic <[EMAIL PROTECTED]> 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() -- http://mail.python.org/mailman/listinfo/python-list