[issue20363] BytesWarnings triggerred by test suite

Arfrever Frehtes Taifersar Arahesis report at bugs.python.org
Thu Jan 23 22:11:40 CET 2014


Arfrever Frehtes Taifersar Arahesis added the comment:

You rather meant [2:-1] instead of [1:-1], but if initial "b'" and final "'" are not needed in result string, then maybe just call .decode() on an instance of bytes.

>>> str(b"xxx")
"b'xxx'"
>>> repr(b"xxx")
"b'xxx'"
>>> repr(b"xxx")[1:-1]
"'xxx"
>>> repr(b"xxx")[2:-1]
'xxx'
>>> b"xxx".decode()
'xxx'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20363>
_______________________________________


More information about the Python-bugs-list mailing list