[Python-ideas] format specifier for "not bytes"

Daniel Holth dholth at gmail.com
Fri Aug 24 20:57:08 CEST 2012


Yes, if I wanted to pretend I was using JavaScript.
A string-only formatter might cause problems with translation string /
gettext type objects?
On Fri, Aug 24, 2012 at 2:40 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On 2012年8月24日 14:33:48 -0400
> Daniel Holth <dholth at gmail.com> wrote:
>> String only would be perfect. I only single out bytes because they are more
>> like strings than any other type.
>> You can use concatenation instead of (or in addition to) formatting:
>>>>> "" + "foo"
> 'foo'
>>>> "" + b"foo"
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: Can't convert 'bytes' object to str implicitly
>>>> "" + 42
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: Can't convert 'int' object to str implicitly
>> Regards
>> Antoine.
>>> --
> Software development and contracting: http://pro.pitrou.net
>>> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas



More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /