[Python-ideas] list / array comprehensions extension

Michael Foord fuzzyman at gmail.com
Thu Dec 15 22:53:56 CET 2011


On 15 December 2011 17:41, Alexander Heger <python at 2sn.net> wrote:

> Dear Oleg,
>
> OK, these work for the examples I listed, I had not tried that. Thanks!
>
> I still think the element extraction would be nice, though.
> what does not work your way is
> x = [1,2,3]
> y = (0,) + x
>
> but
> y = (0,*x)
> could do ... ?
>


In fact there's already an issue for this, with patch:

http://bugs.python.org/issue2292

Actually it goes a lot further than just the syntax you suggest... It
extends tuple unpacking into a few more places as well.

All the best,

Michael Foord


>
> -Alexander
>
>
> On 12/15/2011 11:33 AM, Oleg Broytman wrote:
>
>> On Thu, Dec 15, 2011 at 10:26:50AM -0600, Alexander Heger wrote:
>>
>>> x = [1,2,3]
>>> y = [0,*x]
>>> to obtain [0,1,2,3]
>>>
>>
>> y = [0] + x
>>
>>  or similar for lists
>>> x = (1,2,3)
>>> y = (0,*x)
>>> to obtain (0,1,2,3)
>>>
>>
>> y = (0,) + x
>>
>> Oleg.
>>
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
>



-- 

http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111215/db677c56/attachment.html>


More information about the Python-ideas mailing list