title: Python 3: unsupported operand type(s) for /: 'float' and 'bytes'
body: <p>I am slowly trying to convert an old python 2 code to Python 3, but I hit a roadblock with the following code:</p>
  
  <pre><code>seconds = functools.reduce(lambda x,y:x*60+y,map(int,duration.split(":")))
  </code></pre>
  
  <p>Which gave me:</p>
  
  <blockquote>
    <p>TypeError: 'str' does not support the buffer interface</p>
  </blockquote>
  
  <p>I changed it to:</p>
  
  <pre><code>b'functools.reduce(lambda x,y:x*60+y,map(int,duration.split(":")))'
  </code></pre>
  
  <p>Which made the following line <code>rate = frames/seconds</code> give me this error:</p>
  
  <blockquote>
    <p>TypeError: unsupported operand type(s) for /: 'float' and 'bytes'</p>
  </blockquote>
  
  <p>So I tried to convert the original string to a float like this</p>
  
  <pre><code>seconds = float(functools.reduce(lambda x,y:x*60+y,map(int,duration.split(":"))))
  </code></pre>
  
  <p>But that just resulted in </p>
  
  <blockquote>
    <p>TypeError: 'str' does not support the buffer interface</p>
  </blockquote>
  
  <p>Can anyone please have a look?</p>
  
  <pre><code>import sys,os,re
  import functools
  from subprocess import *
  
  if len(sys.argv)&lt;=1:
    print ("usage: python oneinn.py filename frames")
    sys.exit(0)
  
  try:
    fvideo = sys.argv[1]
    frames = float(sys.argv[2])
  except:
    sys.stderr.write("Failed to parse parameters.\n")
    sys.exit(1)
  
  output = Popen(["ffmpeg", "-i", fvideo], stderr=PIPE).communicate()
  
  # searching and parsing "Duration: 00:05:24.13," from ffmpeg stderr, ignoring the centiseconds
  re_duration = re.compile("Duration: (.*?)\.")
  duration = b're_duration.search(output[1]).groups()[0]'
  
  seconds = float(functools.reduce(lambda x,y:x*60+y,map(int,duration.split(":"))))
  rate = frames/seconds
  
  print ("Duration = %s (%i seconds)" % (duration, seconds))
  print ("Capturing one frame every %.1f seconds" % (1/rate))
  
  output = Popen(["ffmpeg", "-i", fvideo, "-r", str(rate), "-vcodec", "png", 'Preview-%d.png']).communicate()
  </code></pre>