if bytes != str:
Dan Sommers
2QdxY4RzWzUUiLuE at potatochowder.com
Sun Aug 4 11:06:15 EDT 2019
On 8/4/19 10:56 AM, Hongyi Zhao wrote:
> Hi,
>
> I read and learn the the following code now:
>
> https://github.com/shadowsocksr-backup/shadowsocksr-libev/blob/master/src/
> ssrlink.py
>
> In this script, there are the following two customized functions:
>
>
> ----------
> def to_bytes(s):
> if bytes != str:
> if type(s) == str:
> return s.encode('utf-8')
> return s
>
> def to_str(s):
> if bytes != str:
> if type(s) == bytes:
> return s.decode('utf-8')
> return s
> ----------
>
> I've the following confusion on the above code:
>
> Why should use `if bytes != str:' here? I mean, this will always return
> True, IMO.
Not in Python 2:
Python 2.7.16 (default, Mar 11 2019, 18:59:25)
[GCC 8.2.1 20181127] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> bytes != str
False
More information about the Python-list
mailing list