very Very VERY dumb Question About The new Set( ) 's

Raymond Hettinger vze4rx4y at verizon.net
Sat Jul 26 20:09:00 EDT 2003


> > Since both dictionaries and Sets require unique members/keys,
> > why not use the dictionary braces but without the key/value
> > syntax. So:
> >
> > mySet = {1,2,3,4}
> >
> > Which is illegal for a dictionary but would be OK for a Set.
> > It also just happens to be the same delimiters used in math
> > for sets...

>
>
> +1 if Python's parser could handle it (which seems dubious).


FWIW, I think the easiest and most readable syntax is:

    mySet = set(1, 2, 3, 4)

BTW, this is a bit reminiscent of the discussion about a syntax
for entering fixed decimals.  After much discussion, someone
realized the obvious and noted that real programs mostly
take in their fixed point data from external sources and would
rarely appear as a constant in a program; hence, there was no
need for a special syntax -- just Decimal(data) would do the
trick.  (Think about a program like Quicken for checkbook
accounting -- none of the check/deposit amounts are known
in advance so the program is unlikely to contain any fixed
decimal constants except zero and $0.01).


Raymond Hettinger







More information about the Python-list mailing list