[Python-ideas] frozenset literals

Markus Unterwaditzer markus at unterwaditzer.net
Sun Feb 3 00:52:17 CET 2013



Hua Lu <gotoalanlu at gmail.com> wrote:

>This is similar to another proposal:
>http://mail.python.org/pipermail/python-3000/2008-January/011798.html
>
>Anyway, I was using ast.literal_eval and attempted to use
>frozenset({...})
>as a key in a dictionary, which failed, because frozenset isn't a
>literal
>(though putting frozenset in the environment would be a security risk).
>I
>am currently working around this with tuples, but I'd like a literal
>for
>representing frozensets as well. I also use frozensets elsewhere in the
>code in ways similar to Raymond's original suggestion.
>
>Perhaps something like f{...} for declaring frozenset( comprehension)?
>literals?
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>http://mail.python.org/mailman/listinfo/python-ideas

What about {1, 2, 3}.frozen() ? While not exactly new syntax, i think it would be a good short way to create a frozenset.

-- Markus



More information about the Python-ideas mailing list