TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-04 Thread Satish ML
Hi, >>>import struct >>>file = open('data.bin', 'rb') >>>bytes = file.read() >>> records = [bytes([char] * 8) for char in b'spam'] Traceback (most recent call last): File "", line 1, in records = [bytes([char] * 8) for char in b'spam'] File "", line 1, in records = [bytes([char] * 8

Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-04 Thread Ben Finney
Satish ML writes: > >>>import struct > >>>file = open('data.bin', 'rb') Here you re-bind the name ‘file’ to the return value from that call. > >>>bytes = file.read() Here you re-bind the name ‘bytes’ to the return value from that call. > >>> records = [bytes([char] * 8) for char in b'spam']

Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-04 Thread Chris Angelico
On Tue, Aug 5, 2014 at 3:47 PM, Satish ML wrote: bytes = file.read() You've just shadowed the built-in type 'bytes' with your own 'bytes'. Pick a different name for this, and you'll be fine. 'data' would work. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-05 Thread Travis Griggs
> On Aug 4, 2014, at 22:57, Chris Angelico wrote: > > On Tue, Aug 5, 2014 at 3:47 PM, Satish ML wrote: > bytes = file.read() > > You've just shadowed the built-in type 'bytes' with your own 'bytes'. > Pick a different name for this, and you'll be fine. 'data' would work. Until python4 in

Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 3:31 PM, Travis Griggs wrote: >> On Aug 4, 2014, at 22:57, Chris Angelico wrote: >> >> On Tue, Aug 5, 2014 at 3:47 PM, Satish ML wrote: >> bytes = file.read() >> >> You've just shadowed the built-in type 'bytes' with your own 'bytes'. >> Pick a different name for this,

Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2021-12-04 Thread Wasia Maya
You have assigned a bytes value to the name bytes: >>> bytes([10, 20, 30, 40]) b'\n\x14\x1e(' >>> bytes = bytes([10, 20, 30, 40]) >>> bytes([10, 20, 30, 40]) Traceback (most recent call last): File "", line 1, in TypeError: 'bytes' object is not callable bytes is now bound to the value b'\n\x14