Pythonification of the asterisk-based collection packing/unpacking syntax
Hans Mulder
hansmu at xs4all.nl
Thu Dec 22 09:13:22 EST 2011
On 22/12/11 14:12:57, Steven D'Aprano 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!
How about:
<class name="MyClass" superclasses="A, B, C">
<def name="method" arguments="self, x, y">
<let target="t">
<tuple>
<te>1</te>
<te>2</te>
<te><tuple><te>3</te><te>4</te></tuple></te>
</tuple>
</let>
<return>
<multiply>
<add><var>x</var><var>x</var></add>
<subtract><var>x</var><var>x</var></subtract>
</multiply>
</return>
</def>
</class>
More more readable! And it's a standard!
:-)
-- HansM
More information about the Python-list
mailing list