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
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.
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
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,
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
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