How to recover bytes function?

sohcahtoa82 at sohcahtoa82 at
Fri Nov 14 00:16:20 CET 2014

On Thursday, November 13, 2014 2:32:47 PM UTC-8, satish... at wrote:
> file = open('data.bin', 'rb')
> bytes =
> bytes
> b'\x00\x00\x00\x02spam\x00\x03?\x9d\xf3\xb6'
> records = [bytes([char] * 8) for char in b'spam']
> TypeError: 'bytes' object is not callable
> How to recover bytes function?

So how many times do we have to ask you to tell us your EXPECTED output before you start actually doing that?  

'bytes' is a built-in function, but built-in function definitions can be overwritten by redeclaring them.  In this case, you're deleting the bytes function by assigning some read data to `bytes`.  Don't do that.  Either use a variable name other than 'bytes', or recover your bytes function.


More information about the Python-list mailing list