[Python-ideas] Re: Copying a multiple values of a dict to another with a lot easier syntax

2019-10-21 Thread Bar Harel
I believe you made a mess. For all attribute getting needs, I think operator.attrgetter should suffice. No need to implement it yourself. For attribute setting needs, maybe we can add an equivalent operator.attrsetter. I can see myself using it from time to time. Easy solution, solves the

[Python-ideas] Re: Copying a multiple values of a dict to another with a lot easier syntax

2019-10-21 Thread Kyle Lahnakoski
On 2019-10-21 10:44, gedizgu...@gmail.com wrote: m and n are lists or dicts or enumerates or classes or anything it can be assigned like following: instead of : m.a=n.a; m.b=n.b; m.c=n.c; ... I suggest: a,b,c of m to n ; Interesting.  I also saw this type of redundancy in my code.

[Python-ideas] Re: Copying a multiple values of a dict to another with a lot easier syntax

2019-10-21 Thread Steve Jorgensen
Steve Jorgensen wrote: > gedizgursu@gmail.com wrote: > > m and n are lists or dicts or enumerates or classes > > or anything it can be assigned like > > following: > > instead of : > > m.a=n.a; > > m.b=n.b; > > m.c=n.c; > > ... > > I suggest: > > a,b,c of m to n ; > > I thought of this while

[Python-ideas] Re: Copying a multiple values of a dict to another with a lot easier syntax

2019-10-21 Thread Andrew Barnert via Python-ideas
On Oct 21, 2019, at 07:44, gedizgu...@gmail.com wrote: > > m and n are lists or dicts or enumerates or classes or anything it can be > assigned like following: Assigning attributes is different from assigning items to a collection like a list or dict. That’s why there are separate syntaxes,

[Python-ideas] Re: Copying a multiple values of a dict to another with a lot easier syntax

2019-10-21 Thread Steve Jorgensen
gedizgursu@gmail.com wrote: > m and n are lists or dicts or enumerates or classes or anything it can be > assigned like > following: > instead of : > m.a=n.a; > m.b=n.b; > m.c=n.c; > ... > I suggest: > a,b,c of m to n ; > I thought of this while writing something in javascript since I love pyhton

[Python-ideas] Re: Copying a multiple values of a dict to another with a lot easier syntax

2019-10-21 Thread Jonathan Fine
Hi You quite rightly noted that m.a = n.a m.b = m.b m.c = m.c is repetitive. Larger such examples cry out for refactoring. Such can already be done in Python. How about for key in 'a', 'b', 'c': setattr(m, key, getattr(n, key)) If you're doing this a lot, how about a