Idiosyncratic python

Laura Creighton lac at openend.se
Thu Sep 24 23:08:58 CEST 2015


In a message of Thu, 24 Sep 2015 13:46:27 -0700, Ned Batchelder writes:
>On Thursday, September 24, 2015 at 2:02:38 AM UTC-4, Steven D'Aprano wrote:
>> What are your favorite not-wrong-just-weird Python moments?
>
>I've seen this a number of times:
>
>    dict_of_values.update({'key': some_value})
>
>why not:
>
>    dict_of_values['key'] = some_value
>
>I've considered writing a Pylint plugin to flag these...
>
>--Ned.

A student today had a similar version of this one:

Every time he wanted to change the value of dictionary mapping he would
write:
w={'key': new_value}
dict_of_values.update(w)

Laura



More information about the Python-list mailing list