I am migrating one big project from Python 2 -> Python 3, the issue with comparison between "bytes" and "str" only found when the old code run into it and fail explicitly. If it falsely pass, i will not be aware. One example:
def read_var_startaddr(self, var_name):
#__get_var_name() will return bytes
if self.__get_var_name() == var_name:
print("do something")
return self.__get_startaddr()
So i would like to fix this for the whole project, instead of waiting until something happens, there are twos things in my mind:
- Use Notepad++: Search the whole project with regular expression, and checking by eyes ... to make sure no unexpected replacement happen. Search with Notepad++
- I would like the create wrapper the basic operator "==" or "!=", with a purpose to auto convert and compare corresponding values.
My Question: With option 2, Is it possible to do wrap the basic operator, how to do it and what are the impacts it may cause? Is there better way?
Thanks a lot!