On Tue, May 15, 2007 at 02:02:06AM +0200, Thomas Wittek wrote:
> John Macdonald schrieb:
> > It's also, in many cases,
> > harder to edit - that's why a trailing comma in a list that
> > is surrounded by parens, or a trailing semicolon in a block
> > surrounded by braces, is easier to manage.
>
> Now that the list is surrounded by parens makes clear that it ends with
> the closing paren and not with a line break. So you could still use
> commas (without backslashes) to separate the items over multiple lines.
> See e.g. http://docs.python.org/ref/implicit-joining.html
I was actually talking about existing perl5 here. I write:
my %h = (
x => 100,
y => 75,
z => 99,
);
explicitly writing the "unrequired" comma on the last element
(z=>99). That way, if I add another element to the hash there's
no danger that I will forget to go back and add the comma to
the line above. Alternately, if I reorder the hash elements
(maybe sorting on the value instead of the key) I don't have
to check whether there is now a commaless line in the middle
of the reordered bunch.
--