[Python-3000] sets in P3K?

Greg Wilson gvwilson at cs.utoronto.ca
Mon Apr 24 16:16:42 CEST 2006

Hi Guido,

> On 4/24/06, Greg Wilson <gvwilson at cs.utoronto.ca> wrote:
> > On a completely different note, are you willing to consider native
> > syntax for sets (as per PEP 218) in Python 3000?

> I like to write {1, 2, 3} instead of set([1, 2, 3]) but I don't know
> what to do with the ambiguity for {}. I believe you proposed {-} at the
> time which is actually hard to parse (because the '-' looks like the
> start of an expression and with our LL(1) parser there's no way back).
> Ideally perhaps {:} would be an empty dict and {} an empty set -- but
> that will take some getting used to (and would probably break
> compatibility with JSON). Perhaps {/} for an empty set? I'd hate to have
> to say set(). ABC solved this by having a special empty object that
> could become either a list or a table, but I don't think that'll work
> for us -- the implementation would have to have compatible memory
> lay-outs.

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.  I
liked the "special empty object" idea when I first wrote the PEP (i.e.,
have {} be something that could turn into either a set or dict), but one
of the instructors here convinced me that it would just lead to confusion
in newcomers' minds (as well as being a pain to implement).

If anyone else on the P3K list is interested in discussing this, please
email me directly, and we'll see what we can hammer out.  Would getting a
trial implementation done on top of P2.5 be a good Google Summer of Code


More information about the Python-3000 mailing list