VanL / shedskin

Shed Skin is an experimental compiler, that can translate pure, but implicitly statically typed Python (2.4-2.6) programs into optimized C++
0 stars 1 forks source link

Missing file_obj.xreadlines() #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Any code with xreadlines() is confused by it and breaks:

lines = open('file.txt','r').xreadlines()
for line in lines:
    print line

That alone will not know the type of xreadlines, line, or lines, even though 
xreadlines returns an iterable that returns one line at a time. Basically it's 
an fgets operation on the open file. It's a Python 2.1 thing, so it should be 
in the purview of Shedskin.

No rush since .readlines() works alright, but .xreadlines() is necessary for 
really large file that get read in bit by bit.

Original issue reported on code.google.com by fahh...@gmail.com on 5 Dec 2010 at 10:53

GoogleCodeExporter commented 9 years ago
thanks for noticing! :) I added this to the easy-tasks-wiki page for now.

Original comment by mark.duf...@gmail.com on 6 Dec 2010 at 10:34

GoogleCodeExporter commented 9 years ago

Original comment by mark.duf...@gmail.com on 6 Dec 2010 at 10:34

GoogleCodeExporter commented 9 years ago
so it was an 'easy task' for several months, and it took me 5 mins just now.. 
too bad I had to do it myself :P do note that xreadlines is deprecated, and you 
get about the same result with iter(file) or 'for line in file'. still for 
compatibility it's good to implement this. thanks again for mentioning!

Original comment by mark.duf...@gmail.com on 29 May 2011 at 8:55