[Tutor] file-like object
Chad Crabtree
flaxeater at yahoo.com
Fri Jan 14 17:24:21 CET 2005
I have created a file-like object out of a triple quoted string. I
was
wondering if there is a better way to implement readline than what I
have below? It just doesn't seem like a very good way to do this.
class _macroString(object):
def __init__(self,s):
self.macro=s
self.list=self.macro.split("\n")
for n,v in enumerate(self.list):
self.list[n]=v+'\n'
def readline(self,n=[-1]):
n[0]+=1
return self.list[n[0]]
def __str__(self):
return str(self.list)
def __len__(self):
return len(self.list)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Tutor
mailing list