On Sat, Feb 5, 2011 at 15:38, Steven D'Aprano
<[email protected]> wrote:
> On Sat, 05 Feb 2011 14:38:29 +0100, Daniel Urban wrote:
>
>> On Sat, Feb 5, 2011 at 14:08, Lisa Fritz Barry Griffin
>> <[email protected]> wrote:
>>> Hi there,
>>>
>>> How can I do this in a one liner:
>>>
>>> maxCountPerPhraseWordLength = {}
>>> for i in range(1,MAX_PHRASES_LENGTH+1):
>>> maxCountPerPhraseWordLength[i] = 0
>>
>> maxCountPerPhraseWordLength = {0 for i in range(1,MAX_PHRASES_LENGTH+1)}
>
> Unfortunately not. In versions before Python 2.7, it will give a
> SyntaxError. In 2.7 or better it gives a set instead of a dict:
Yeah, sorry, that should have been {i: 0 for i in
range(1,MAX_PHRASES_LENGTH+1)}
Daniel
--
http://mail.python.org/mailman/listinfo/python-list