• Advertisement
Sign in to follow this  

python IO problem

This topic is 2926 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

heey all, at the moment i'm back to python and it's file IO. I have a list of strings that should be formatted and saved. At the moment this works and write the strings to a file
def writeProto(self, filename):
    stream = open(filename, "w")
    endstring = ""
    for name in self.parent.finder.namelist:
      #expObjType = self.parent.finder.GetType(expObj)
      #expObjID = self.parent.finder.GetID(expObj)
      
      #the name is shown correctly
      print name
      
      #enstring = "o %s" % (str(name))
      
      #write the damn thing to a file
      stream.write(name)
      stream.write("\n")
      
    #close the file
    stream.close()

But as soon as i change it to this it doesn't write a thing but it still prints the names
def writeProto(self, filename):
    stream = open(filename, "w")
    endstring = ""
    for name in self.parent.finder.namelist:
      #expObjType = self.parent.finder.GetType(expObj)
      #expObjID = self.parent.finder.GetID(expObj)
      
      #the name is still shown correct
      print name
      
      enstring = "o %s" % (str(name))
      
      #write the damn thing to a file
      stream.write(endstring)
      stream.write("\n")
      
    #close the file
    stream.close()

Can anybody see why it doesn't work? thanks in advance, assainator

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement