[Tutor] file-like object
Alan Gauld
alan.gauld at freenet.co.uk
Fri Jan 14 18:20:15 CET 2005
> 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]]
Why not just create a current pointer as a clas attribute?
Increment or reset as required. after all maintaining
object state is what classes and objects are for!
HTH,
Alan G.
More information about the Tutor
mailing list