Pythonification of the asterisk-based collection packing/unpacking syntax

Eelco hoogendoorn.eelco at gmail.com
Mon Dec 19 05:20:33 EST 2011


On Dec 19, 1:59 am, Rick Johnson <rantingrickjohn... at gmail.com> wrote:
> On Dec 17, 11:33 pm, Evan Driscoll <edrisc... at wisc.edu> wrote:
>
> > On 12/17/2011 22:52, buck wrote:> Try these on for size.
>
> > >      head, @tuple tail = sequence
> > >      def foo(@list args, @dict kwargs): pass
> > >      foo(@args, @kwargs)
>
> > > For backward compatibility, we could say that the unary * is identical to @list and unary ** is identical to @dict.
>
> > I like this idea much more than the original one.
>
> +1. I will second that! Eelco has the CORRECT idea, but the WRONG
> syntax!

Thanks, your opinion is noted.

Personally im impartial between identifier::collectiontype and
identifier at collectiontype, but that order is something I think is
rather important.

Having two seperate symbols seperated by whitespace, as in @list args
strikes me as a terrible break of normal python lexical rules. Plus,
identifier at collectiontype as a collection-type annotation would be
consistent with the existing general function annotation syntax. Many
non-C-family languages postfix the type declaration.

Also, we want to use the same symbol for collection unpacking as we
use for collection packing. Saying foo(@argslist) really does look a
tad much like a decorator, even though it can be unambigiously
distinguished from it by context.



More information about the Python-list mailing list