[Python-3000] Set literal
Mark Summerfield
mark at qtrac.eu
Fri Jan 25 08:18:23 CET 2008
On 2008-01-25, Guido van Rossum wrote:
> For the record, I'm thinking Raymond has won this argument fair and
> square, and I'm withdrawing my opposition.
>
> I hope it isn't too confusing that {1: 1} creates a *mutable* dict
> while {1} creates an *immutable* frozenset. I still find this slightly
> inelegant. But the practicality of being able to treat set literals as
> compile-time constants wins me over.
So this will produce:
frozenset() # empty frozen set
{1} # 1 item frozen set
{1, 2} # 2 item frozen set
{} # empty dict
{1:1} # 1 item dict
{1:1, 2:2} # 2 item dict
I think this is confusing and messy, especially for new Python programmers.
If you're going to make the change, why not make things consistent:
{} # empty frozen set
{1} # 1 item frozen set
{1, 2} # 2 item frozen set
{:} # empty dict
{1:1} # 1 item dict
{1:1, 2:2} # 2 item dict
--
Mark Summerfield, Qtrac Ltd., www.qtrac.eu
More information about the Python-3000
mailing list