[Python-3000] sets in P3K?

Steven Bethard steven.bethard at gmail.com
Tue Apr 25 00:48:35 CEST 2006


On 4/24/06, Raymond Hettinger <rhettinger at ewtllc.com> wrote:
> Greg Wilson wrote:
>
> >I'm sure we can work something out --- I agree, {} for empty set and {:}
> >for empty dict would be ideal, were it not for backward compatibility.
> >
[snip]
> Further, punctuation approaches face uncomfortable choices with respect
> to iterables.  Would {range(3)} be allowed?  If not, then you've lost a
> key bit of functionality and imposed an arbitrary restriction.  If so,
> then do you allow something similar for dicts?  If not, then you've
> introduced another arbitrary inconsistency.  If so, then you face more
> challenges distinguishing between sets and dicts -- is {somegen()} a set
> or dict -- there are valid interpretations either way if somegen()
> returns tuples.

While I agree with all your other arguments (and I'm perfectly happy
to write dict(), set() and list() when necessary), I think there's no
reason to be confused about something like ``{range(3)}``.  It would
work exactly like list literals do:

    >>> [range(3)]
    [[0, 1, 2]]

This is not an "arbitrary restriction" -- unless you believe that
lists also have such an arbitrary restricion.

STeVe
--
Grammar am for people who can't think for myself.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list