[Python-ideas] The "in"-statement
tjreedy at udel.edu
Mon Nov 5 22:48:42 CET 2012
On 11/5/2012 2:28 PM, Markus Unterwaditzer wrote:
> This is my first post on this mailinglist and i haven't lurked a long time yet,
> so please be gentle.
> While mocking objects, i got annoyed by the following code pattern i had to
> use when modifying multiple attributes on a single object::
> obj.first_attr = "value"
> obj.second_attr = "value2"
o = obj # solves most of the 'problem' of retyping 'obj' over and over
o.first_attr = 'aval'
o.sec = o.third(1, o.fourth)
If the original is
obj.first = first
obj.second = second
as in common in __init__, then your solution
first = first
second = second
requires disambiguation by, I presume, position.
New syntax must add something that is not trivial to do now.
Terry Jan Reedy
More information about the Python-ideas