How to recover bytes function?

Cameron Simpson cs at zip.com.au
Fri Nov 14 02:46:09 EST 2014


On 13Nov2014 14:32, satishmlmlml at gmail.com <satishmlmlml at gmail.com> wrote:
>file = open('data.bin', 'rb')
>bytes = file.read()
>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?

The best way is not to use "bytes" for something else when you know you will be 
using the builtin version as well. Using the same name for two things is 
generally a bad idea.

The second, and worse, way is to see the documentation for the "builtins" 
module.

Cheers,
Cameron Simpson <cs at zip.com.au>

Madness takes its toll.  Please have exact change.
        - Janice Hanes <janice at anv.net>



More information about the Python-list mailing list