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

Chris Angelico rosuav at gmail.com
Wed Aug 6 01:37:10 EDT 2014


On Wed, Aug 6, 2014 at 3:31 PM, Travis Griggs <travisgriggs at gmail.com> wrote:
>> On Aug 4, 2014, at 22:57, Chris Angelico <rosuav at gmail.com> wrote:
>>
>> On Tue, Aug 5, 2014 at 3:47 PM, Satish ML <satishmlwizpro at gmail.com> 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 introduces the 'data' built in. :)

Python 3.6 could introduce that, no need to wait for Python 4. :)
However, it wouldn't be critical to this code, unless the builtin's
meaning is also wanted; it'd be on par with the shadowing of 'file'
earlier - given how rarely Python programs actually need 'file'
(rather than 'open'), it's not a big deal to shadow that one.

ChrisA



More information about the Python-list mailing list