On 1/28/08, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Guido van Rossum wrote:
> > On Jan 26, 2008 8:39 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:

> >>However, my support for it has waned anyway.  The
> >> notation is also used for set comprehension
> >> and those should be mutable.

Set comprehensions don't appear yet in 2.5, so they aren't yet an
immovable constraint.

How often are set comprehensions needed, and how often must they be mutable?

In my own code, I already tend to treat even the results of a list
comprehension as immutable.  Normally, the result is already a
complete set, and when it isn't, the code is already awkward as I
digress to get the other members.

    res = tupleA + tupleB

wouldn't really be any worse than

    res.extend(listB)

and I would actually prefer

    res = setA.union(setB)

> Another possibility would be to drop set comprehension
> syntax and just require people to use set(genexp).

This looks fine to me, but again, I usually just iterate through it
once, so I typically use list even when a set would be more
semantically correct.

> Or have set comprehensions produce frozensets and require
> set(genexp) to get a mutable set.

Absolutely ... why are the default sets mutable?  When I want a
mutable set, I almost always start with an empty set.  Even when I
have initial members, they usually come from another container, and
turning them into a set is (mentally) more of a casting than a
comprehension.

-jJ
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to