Oct-31-2018, 10:44 PM
i find many times i write some code or a function or a method that does something with strings and i want it to also handle byte strings since i use those a lot. so initially i coded a test like:
if isinstance(variable,(bytes,bytearray)): ...which woks OK in Python3 but fails in Python2 because bytes is the same as str in Python2. so, i came up with this way to do the test so that it only tests for bytearray when in Python2 when bytes is the same as str:
if isinstance(variable,(bytes,bytearray)[bytes==str:]): ...
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.