builtin set literal

MRAB google at mrabarnett.plus.com
Thu Feb 15 20:25:12 EST 2007


On Feb 15, 4:12 pm, Schüle Daniel <u... at rz.uni-karlsruhe.de> wrote:
> [...]
>
> >>> In Python 3.0, this looks like::
>
> >>>     s = {1,2,3}
>
> >> jepp, that looks not bad .. as in a mathe book.
> >> the only disadvantage I see, that one may confuse it with a dict.
>
> > Perhaps with a very cursory inspection. But the lack of any ':'
> > characters is a pretty quick clue-in.
>
> there is one a bigger disadvantage though
> {} empty set clashes with empty dict {}
> set() still must be used to generate the empty set
> or a hack like
> s = {None}.clear()
>
> I think something like {-} as the substitution for empty set
> will seem bit to perlish for most of us? :)
>
What about "{,}"? For consistency "(,)" and "[,]" might also have to
be permissible, and maybe even "{:}" for an empty dict. Or perhaps not.




More information about the Python-list mailing list