Nov-01-2018, 09:18 AM
(This post was last modified: Nov-01-2018, 09:20 AM by Gribouillis.)
I think the best way is to avoid type checking. You have at least two options
- Write functions with different names for str and bytes, for example
spam(x)
for unicode andbspam(x)
for bytes.
- Use generic functions (singledispatch) to select according to the first argument's type.