Rick Johnson於 2013年2月11日星期一UTC+8下午9時13分58秒寫道: > On Monday, February 11, 2013 6:40:23 AM UTC-6, Chris Angelico wrote: > > > [...] > > > Or doing what you were pointing and laughing at Pike for, and using > > > two-symbol delimiters. You could even make it majorly logical: > > > > > > list_ = [[ 1, 2, 3 ]] > > > tuple_ = ([ 1, 2, 3 ]) > > > dict_ = [{ 1, 2, 3 }] > > > frozendict_ = ({ 1, 2, 3 }) > > > set_ = [< 1, 2, 3 >] > > > frozenset_ = (< 1, 2, 3 >) > > > > I am vehemently against using more than one "opening seq char" and one > "closing seq char". It works fine for single depth sequences, however, once > you start nesting the mental focus required to parse the doubled > openers/closers is headache inducing. I would accept wrapping the literal in > some sort of declaration though, something like i proposed earlier in the > thread. The easiest is to use: > > > > set({1,2,3}) > > > > but that looks like a function call! So we'd need a unique syntax. Either a > single tag like: > > > > set{1,2,3} > > > > Or we could use start and end tags like: > > > > set{1,2,3}set > > > > where "set{" and "}set" are delimiters. For lists, tuples, and dict we would > use the short form because these literals are far too ubiquitous: > > > > [1,2,3] # list > > {k:v} # dict > > (1,2,3) # tuple > > > > However, the grouping chars for tuples has always been confusing because they > can clash with grouping of expressions. What is this? > > > > (1) > > > > It's NOT a tuple! But it looks like a tuple! What is this: > > > > 1,2 > > > > it IS a tuple, but it does not look like a tuple! > > > > That's an unfortunate side effect of a poorly thought-out tuple syntax.
I am thinking a mutated list temporarily is useful when a list is to be used to be iterated through all of its elements efficiently. A permanently mutated list is a tuple of constant objects. As for the set type, I prefer to use the operations of the list, dictionaries in Python to act for the designed purposes. -- http://mail.python.org/mailman/listinfo/python-list