George Sakkis <[EMAIL PROTECTED]> writes:

> On Feb 12, 7:02 pm, Ben Finney <[EMAIL PROTECTED]>
> wrote:
> > That makes it even more a violation of
> > principle-of-least-astonishment that the '(foo)' form doesn't give
> > a one-element tuple literal.
> 
> The reason being, of course, that in this case '(1+2) * 3' would
> give a result several orders of magnitude more astonishing,

Yes, of course.

> so it's well worth the slight inconvenience of one-element tuples.

I didn't make it clear, but my expected solution to this is that '()'
should not create an empty tuple (as I was clearly assuming earlier in
this thread). An empty set can still be created with 'set()'.

That way, it becomes clearer that it's the comma separator, not the
parens, that create a tuple literal. With '()' creating an empty tuple
literal, and '(foo, bar)' creating a two-element tuple literal, it
remains that much harder to remember that '(foo)' does *not* create a
tuple.

-- 
 \       “Imagine a world without hypothetical situations.” —anonymous |
  `\                                                                   |
_o__)                                                                  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to