On 4/25/06, Edward Loper <[EMAIL PROTECTED]> wrote:
> I think that a significant motivation for people that propose set
> literals is that the following is just plain ugly:
>
> s = set([1,2,3])
>
> It seems much more natural to write:
>
> s = set(1, 2, 3)
>
> s = set.from_iter(my_list)
> s = set.from_iter(enumerate(my_list))
> s = set.from_iter(x for x in collection if x>10)
Alternatively, define a classmethod for the literal form. For me,
even the much longer
s = set.literal(1, 2, 3)
would be much better than
s = set([1,2,3])
Nick's NumPy-inspired suggestion of
s = set[1, 2, 3]
is probably even better, though I'm not sure I would like what it does
to the rest of the language. (The [] vs () would be arbitrary
(historical), and
Class.__getitem__() would be almost unrelated to
Class().__getitem__(). )
-jJ
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com