Too Self Centered

beno zope at thewebsons.com
Tue Jan 7 15:53:40 EST 2003


Hi;
I'm writing my first real script and running into what appears to be a 
problem. Although this code works perfectly well, it seems to have way too 
many uses of *self.* in it. But if I don't put them in, the runtime 
compiler complains that various global names aren't defined. What to do? 
Here's an example of the code.
TIA,
beno

  def __init__(self):
   self.readFile = open('test1','r')
   while self.readFile.readline() != '':
    self.count = self.count + 1
   self.total = self.count
   self.readFile.close()
  def firstRead(self):
   self.readFile = open('test1','r')
   self.name = self.readFile.readline()
   self.count = self.count - 1
  def subsequentRead(self):
   if self.count != 0:
    self.lines.append(self.readFile.readline())
    self.count = self.count - 1
    self.subsequentRead()
   else:
    pass
  def firstLine(self):
   self.allLines += self.lines[0]
  def subsequentLines(self):
   if self.total > 2:
    self.total = self.total - 1
    self.countOne = self.countOne + 1
    self.allLines += self.lines[self.countOne]
    self.subsequentLines()
   else:
    table = string.maketrans('\n', ' ' )
    self.allLines = string.translate(self.allLines,table)







More information about the Python-list mailing list