3 ms·
"\x01\x02".encode('zlib') is a really odd API. Just making sure: this is a real thing, and you're in favor of it?
by bronson 11y ago
"\x01\x02".encode('zlib') is a really odd API. Just making sure: this is a real thing, and you're in favor of it?
- the_mitsuhiko 11y ago> "\x01\x02".encode('zlib') is a really odd API. Just making sure: this is a real thing, and you're in favor of it? Of course this is a real thing and it's very frequently used. Yes I am in favour of it as the codec system in Python is precisely the place where things like this should live.
- tveita 11y agoIt is in Python 2, but not in Python 3, where str.encode() and bytes.decode() have been restricted to only convert between strings and bytes. >>> "foo".encode('zlib') LookupError: 'zlib' is not a text encoding; use codecs.encode() to handle arbitrary codecs