[Python-3000] Set literal
Steven Bethard
steven.bethard at gmail.com
Fri Jan 25 21:41:36 CET 2008
On Jan 25, 2008 1:31 PM, J. Cliff Dyer <jcd at sdf.lonestar.org> wrote:
>
> I'm a -0.9 on this one. I really like that Python is powerful, but also a
> great pedagogical language.
>
> I don't like that whereas before you could teach someone {} creates a dict,
> but now you have to say {} creates a dict, if there are colons inside, or
> it's empty, but otherwise creates a frozenset. I also don't like that it
> will be easy (especially coming from Certain Other Languages) to make the
> following error:
>
> my_dict = {
> 'a', 'b',
> 'c', 'd',
> 'e', 'f'
> }
>
> Moreover, I don't like that once you've done that, you'll be able to do
>
> if 'c' in my_dict:
> ...
>
> and have it evaluate as true even though you aren't dealing with a dict.
You're a little late for this discussion. Python 3.0 already has this
behavior::
Python 3.0a2+ (py3k:60260, Jan 25 2008, 13:40:11)
[MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> my_dict = {
... 'a', 'b',
... 'c', 'd',
... 'e', 'f',
... }
>>> 'c' in my_dict
True
This discussion is about whether the set literal should be a set() or
a frozenset().
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
More information about the Python-3000
mailing list