Pythonification of the asterisk-based collection packing/unpacking syntax

Eelco hoogendoorn.eelco at gmail.com
Sat Dec 24 09:54:07 EST 2011


On Dec 22, 2:12 pm, Steven D'Aprano <steve
+comp.lang.pyt... at pearwood.info> wrote:
> On Thu, 22 Dec 2011 06:49:16 -0500, Neal Becker wrote:
> > I agree with the OP that the current syntax is confusing.  The issue is,
> > the meaning of * is context-dependent.
>
> Here you are complaining about an operator being "confusing" because it
> is context-dependent, in a post where you strip all context except the
> subject line and expect us to still understand what you're talking about.
> There's a lesson there, I'm sure.
>
> * is context dependent. You know what else is context dependent? Well,
> most things. But in particular, parentheses. Clearly they must be
> "confusing" too. So how about we say:
>
> class MyClass superclasslist A, B C:
>     def method argumentlist self, x, y:
>         t = tuple 1, 2 tuple 3, 4 endtuple endtuple
>         return group x + y endgroup * group x - y endgroup
>
> Much less confusing!
>
> --
> Steven

Context dependence is not something to be avoided at all costs, but
all else being equal, less is certainly more. The general concept of
grouping thing together which parenthesis is an extremely pervasive
one in programming, and thus deserves its own set of context-dependent
rules. Packing and unpacking collections is far, far more rare, and
thus a form that requires you to write more but remember less is
certainly relatively favorable.



More information about the Python-list mailing list