[Python-3000] sets in P3K?

Jim Jewett jimjjewett at gmail.com
Wed May 3 17:41:24 CEST 2006


On 5/2/06, Raymond Hettinger <rhettinger at ewtllc.com> wrote:

> I think Guido had the best solution.  Use set() for empty sets, use {}
> for empty dicts, use {genexp} for set comprehensions/displays, use
> {1,2,3} for explicit set literals, and use {k1:v1, k2:v2} for dict
> literals.  We can always add {/} later if demand exceeds distaste.

I understand {1,2,3} vs {k1:v1, k2:v2}, but what is the {genexp} for?

As I read that, if the generator yielded two-tuples, you would get a
set of two-tuples rather than a dict.  There would be no comprehension
syntax for dicts.

I'm not sure we need a comprehension syntax for dicts, but I'm not
sure we need one for sets either.

    >>> set(gen())

doesn't seem any worse than

    >>> dict(gen())

-jJ


More information about the Python-3000 mailing list