[Python-3000] Set literal

Mark Summerfield mark at qtrac.eu
Fri Jan 25 10:29:49 CET 2008


On 2008-01-25, Steven Bethard wrote:
> On Jan 25, 2008 12:18 AM, Mark Summerfield <mark at qtrac.eu> wrote:
> > 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
>
> This has been discussed and rejected as it would break too much code.
> Check the archives during the set literals discussions.
>
> STeVe

Python 3 is going to break compatibility anyway. I thought one of the
purposes of having a new major release was to allow for such changes.

In 2 or 3 years from now Python 3 will be "Python" for most people, and
confusing inconsistencies won't be seen to have any rationale.

-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu



More information about the Python-3000 mailing list