title: Structures packing/unpacking class design
body: <p>I'm implementing binary file format (~15 different structures) reader/writer and i have a bit dilemma which design pattern i should use.</p>
  
  <ol>
  <li><p>Each structure contains method for pack/unpack: </p>
  
  <pre><code>class Struct1:  
      def pack():
          struct.pack(self.foo)
          ...
      def unpack():  
          self.foo = struct.unpack()
          ...
  class Struct2:  
      def pack():
          struct.pack(self.foo)
          ...
      def unpack():  
          self.foo = struct.unpack()
          ...
  ...
  </code></pre>
  
  <p>vs.  </p></li>
  <li><p>There is Reader/Writer class with read/write method for each structure:</p>
  
  <pre><code>class Reader:
      def read_struct1():
          s = Struct1()
          s.foo = struct.unpack()
          ...
          return s
      def read_struct2():
          s = Struct2()
          s.foo = struct.unpack()
          ...
          return s
      ...
  class Writer:
      def write_struct1(s):
          struct.pack(s.foo)
          ...
      def write_struct2(s):
          struct.pack(s.foo)
          ...
      ...
  </code></pre></li>
  </ol>