Satish ML
unread,Aug 5, 2014, 1:47:51 AM8/5/14You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
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 "<pyshell#99>", line 1, in <module>
records = [bytes([char] * 8) for char in b'spam']
File "<pyshell#99>", line 1, in <listcomp>
records = [bytes([char] * 8) for char in b'spam']
TypeError: 'bytes' object is not callable
If we code something like given below, it works.
>>> records = [([char] * 8) for char in b'spam']
>>> records
[[115, 115, 115, 115, 115, 115, 115, 115], [112, 112, 112, 112, 112, 112, 112, 112], [97, 97, 97, 97, 97, 97, 97, 97], [109, 109, 109, 109, 109, 109, 109, 109]]
Could you kindly help me resolve this problem of converting to bytes?