Message306617
I got your point, missed it before, sorry.
So just for completeness.
My issue was basically about the ambiguity of the str()-constructor
and the str()-built-in-function. Therefore the len/type prints.
It works with parameters:
(3.6.2) [acue@lap001 Desktop]$ python -bb
Python 3.6.2 (default, Jul 29 2017, 14:24:56)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> str(b"abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
BytesWarning: str() on a bytes instance
>>>
>>>
>>> str(b"abc", "utf-8")
'abc'
>>>
>>> type(str(b"abc",'utf-8'))
<class 'str'>
>>>
Is there a common approach to force the use of the str()-constructor instead of
the str()-built-in function and/or the __str__()-method?
This would make the shared code of Python2/Python3 much easier,
at least for unicode()->str(). |
|
Date |
User |
Action |
Args |
2017-11-21 02:54:03 | acue | set | recipients:
+ acue, vstinner, ezio.melotti |
2017-11-21 02:54:03 | acue | set | messageid: <1511232843.51.0.213398074469.issue32078@psf.upfronthosting.co.za> |
2017-11-21 02:54:03 | acue | link | issue32078 messages |
2017-11-21 02:54:02 | acue | create | |
|