Well, you can have this today!
#############################################################################
class File:
def __init__(self,name,mode='r'):
self.file=open(name,mode)
def __getitem__(self,i):
line=self.file.readline()
if not line:
raise IndexError
return line
file=File('File.py')
for line in file:
print line,
#############################################################################
Ok, file[i] has a very strange semantic.... :
file[i] is not file[i] :-)
Michael
P.S.: with the __{get,set,del}attr__ extension add:
class File:
...
def __getattr__(self,name):
return getattr(self.file,name)
and it will behave like a normal file....
-- __________________________________________________________ **** ___ _ _ ___ _ ****** | __) | \/ | | ) | | Michael Scharf ******** | _) | | | -< | |_ Tel: +49 6221 387 305 Fax: 517 * **** |___) |_||_| |___) |___) EMail: scharf@EMBL-Heidelberg.de **** __________________________________________________________