On Fri, Oct 23, 2020 at 10:19:07AM +0200, Alex Hall wrote:
> On Fri, Oct 23, 2020 at 5:27 AM Steven D'Aprano <st...@pearwood.info> wrote:
> 
> > Background
> > ----------
> >
> > Iterable unpacking assignment:
> >
> >     values = (1, 2, 3)
> >     a, b, c = *values
> >
> > is a very successful and powerful technique in Python.
> >
> 
> Your proposed syntax seems to rest on being similar to this syntax for
> iterable unpacking. But that asterisk isn't valid syntax, so I'm confused.

Oops, you are absolutely right, I confabulated that from the similar 
unpacking that does work:

    py> [1, 2, *"abc", 3]
    [1, 2, 'a', 'b', 'c', 3]

and in function calls. Sorry for the confusion. I swear, no matter how 
well I know Python, the moment I don't test something in the REPL, I'm 
sure to get it wrong *wink*


> but that doesn't make it make sense to write `... = **values` as you
> suggest.

Iterator unpacking on a dict already works:

    py> d = {'a': 10, 'b': 20}
    py> spam, eggs = d
    py> spam, eggs
    ('a', 'b')

so we need to distinguish the iterator unpacking case from the dict 
unpacking case. To me it makes sense to use the same double star used in 
dict unpacking inside dict displays and function calls.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MDJVLDLTGLV3J2IJHXKS62YVRGADVJXH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to