[Python-ideas] The "in"-statement

Mike Graham mikegraham at gmail.com
Mon Nov 5 21:29:06 CET 2012


On Mon, Nov 5, 2012 at 2:49 PM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> On 05.11.12 21:28, Markus Unterwaditzer wrote:
>>
>> I thought it would be neat if i could do::
>>
>>      in obj:
>>          first_attr = "value"
>>          second_attr = "value2"
>
>
>     vars(obj).update(
>         first_attr="value",
>         second_attr="value2",
>         )
>
> Or obj.__dict__.update.

Tinkering with the object's attribute dict directly using either of
these is extremely error-prone because it does not work for many
objects and because it circumvents the descriptor protocol.

Mike



More information about the Python-ideas mailing list