title: Creating a custom file like object python suggestions?
body: <p>Hi i am looking to implement my own custom file like object for an internal binary format we use at work(i don't really want to go into too much detail because i don't know if i can). I am trying to go for a more pythonic way of doing things since currently we have two functions read/write(each ~4k lines of code) which do everything. However we need more control/finesse hence the fact of me rewriting this stuff.</p>
  
  <p>I looked at the python documentation and they say what methods i need to implement, but don't mention stuff like <strong>iter</strong>() / etc.</p>
  
  <p>Basically what i would love to do is stuff like this:</p>
  
  <pre><code>output_file_objs = [
      open("blah.txt", "w")
      open("blah142.txt", "wb")
      my_lib.open("internal_file.something", "wb", ignore_something=True)
  ]
  
  data_to_write = &lt;data&gt;
  
  for f in output_file_objs:
      f.write(data_to_write)
  </code></pre>
  
  <p>So i can mix it in with the others, and basically have a level of transparency. I will add custom methods to it, but thats not a problem. </p>
  
  <p>Is there any sort of good reference regarding writing your own custom file like objects? Like any form of restrictions or special methods (<strong>iter</strong>). I should implement?</p>
  
  <p>Or is there a good example of one from within the python standard library that i can look at?</p>