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/2005-October/057479.html below:

[Python-Dev] list splicing

[Python-Dev] list splicingChristos Georgiou tzot at mediconsa.com
Thu Oct 20 23:08:12 CEST 2005
"Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote in message 
news:432E4BC9.1020100 at canterbury.ac.nz...
> Karl Chen wrote:
>> Hi, has anybody considered adding something like this:
>>     a = [1, 2]
>>     [ 'x', *a, 'y']
>>
>> as syntactic sugar for
>>     a = [1, 2]
>>     [ 'x' ] + a + [ 'y' ].
>
> You can write that as
>   a = [1, 2]
>   a[1:1] = a

I'm sure you meant to write:

a = [1, 2]
b = ['x', 'y']
b[1:1] = a

Occasional absence of mind makes other people feel useful!


PS actually one *can* write

a = [1, 2]
['x', 'y'][1:1] = a

since this is not actually an assignment but rather syntactic sugar for a 
function call, but I don't know how one would use the modified list, since

b = ['x','y'][1:1] = a

doesn't quite fulfill the initial requirement ;) 


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