Issue 17685: Frozenset literal? - Python tracker (original) (raw)
Hi,
I am willing to bet that this has been discussed before, but I don't see any related bugs.
I have been using Python for a while now as a prototyping language for scientific applications. Most recently I have been using it for prototype program analyses.
In this kind of work you are usually transcribing pseudo-code, defined in terms of sets, vectors and mappings into Python syntax. Inevitably, you need to store sets of sets, or you need to do some other operation that requires a hashable data structure.
As a result, I never use sets. I usually resort to using frozensets, which are hashable, yet the syntax for creating these is very verbose:
frozenset([e1, e2, ...])
To counter this, I usually use the following hack:
fs = frozenset
then frozensets can be instantiated like this:
fs([e1, e2, ...])
But this is not ideal. I can't help wondering why there is not a frozenset literal. I see that the mutable set recently got a literal, but why not frozenset?
Cheers!
See the (inconclusive) python-ideas thread starting here:
http://mail.python.org/pipermail/python-ideas/2013-February/019205.html
I'm going to close this issue: the python-ideas mailing list is better suited for this kind of open-ended discussions (though it would be fine to re-open an issue with a specific, detailed proposal for a change---one that a patch could reasonably be written for). You could resurrect that python-ideas thread, or start a new one, if you want to renew the discussion.