Closed ArtemIsmagilov closed 5 months ago
I'm not so sure this one is an improvement (especially when introducing legacy % string formatting).
I didn't write any of this code originally, but if I was to rewrite it, I'd just lose the lists:
args = (str(a).encode() for a in (flags, exptime, len(value)))
_cmd = b" ".join((command, key, *args))
@Dreamsorcerer. Hi, thanks for your comment. Let me explain why I decided to rewrite the code this way.
args
commandOK, I reminded myself about bytes interpolation today. I think I'd be fine with your original idea if you dropped the f-strings and used b"%b %b %a %a %a"
to format it in one step (note that %s
is actually deprecated and likely won't work in Python 4).
OK, I reminded myself about bytes interpolation today. I think I'd be fine with your original idea if you dropped the f-strings and used
b"%b %b %a %a %a"
to format it in one step (note that%s
is actually deprecated and likely won't work in Python 4).
Thank you for considering this issue and reminding us about the outdated %s. I will finish the PR.
try use more simple code with literals(remove join and list comprehension) python use by default encoding utf-8