A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-February/138153.html below:

[Python-Dev] (no subject)

[Python-Dev] (no subject) [Python-Dev] (no subject)Antoine Pitrou solipsis at pitrou.net
Wed Feb 11 12:22:22 CET 2015
On Wed, 11 Feb 2015 18:45:40 +1300
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Antoine Pitrou wrote:
> >>>>bytearray(b"a") + b"bc"
> > 
> > bytearray(b'abc')
> > 
> >>>>b"a" + bytearray(b"bc")
> > 
> > b'abc'
> > 
> > It's quite convenient.
> 
> It's a bit disconcerting that the left operand wins,
> rather than one of them being designated as the
> "wider" type, as occurs with many other operations on
> mixed types, e.g. int + float.

There is no "wider" type here. This behaviour is perfectly logical.

> In any case, these seem to be special-case combinations.

No:

>>> b"abc" + array.array("b", b"def")
b'abcdef'
>>> bytearray(b"abc") + array.array("b", b"def")
bytearray(b'abcdef')

Regards

Antoine.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4