7 Mar
2011
7 Mar
'11
2:13 a.m.
On 3/6/2011 4:06 PM, Mart Sõmermaa wrote:
Which do you prefer: bar = dict(chunk.split('=') for chunk in foo.split(",")) or bar = (dict(chunk.split('=') for chunk in foo.split(",")) if foo else {})
Others have pointed out that one example is not representative of the universe of use cases of split. However, the irony of this example is the *you* are the one who prefers to add 'if s != '' else []' to the definition of s.split(c) ;-). -- Terry Jan Reedy