Reputation: 13206
I am using a program where Python is the native scripting language. Unfortunately, they have a native function that uses the name bytes
. This causes a problem when I am trying to use the actual bytes
built-in function, and it thinks I am referencing that built-in variable. I will show you what I mean, one object as the following built-in code:
def receive(row, table, message, bytes):
#This is defined in the GUI
So, row
, table
, message
, and bytes
are all passed in as arguments, effectively overwriting the name bytes
. So if I were to say bytes(something).decode()
I get a TypeError: 'bytes' object is not callable
Is there any way to get out of this jam?
Upvotes: 2
Views: 58
Reputation: 46533
Your problem is similar to this one. Just from builtins import bytes as _bytes
; this will let you do _bytes(something).decode()
.
Although renaming the fourth argument is a better solution.
Upvotes: 3
Reputation: 368954
Use a different name for the fourth parameter (if you can change the signature of the function)
def receive(row, table, message, bytes_):
#This is defined in the GUI
Upvotes: 3