Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87797 > unrolled thread

Re: __iadd__ with 2 args?

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2015-03-20 15:33 -0600
Last post2015-03-20 15:33 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: __iadd__ with 2 args? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-20 15:33 -0600

#87797 — Re: __iadd__ with 2 args?

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-03-20 15:33 -0600
SubjectRe: __iadd__ with 2 args?
Message-ID<mailman.48.1426887270.10327.python-list@python.org>
On Fri, Mar 20, 2015 at 3:25 PM, Neal Becker <ndbecker2@gmail.com> wrote:
> I can write a member
>
> F.__iadd__ (self, *args)
>
> and then call it with 2 args:
>
> f = F()
> f.__iadd__ (a, b)
>
> And then args is:
> (a, b)
>
> But it seems impossible to spell this as
>
> f += a, b
>
> That, instead, results in
>
> args = ((a, b),)
>
> So should I just abandon the idea that += could be used this way?

Is there some reason you need the *? Just have it take one argument
which will be a tuple.

>>> class F:
...   def __iadd__(self, other):
...     print(other)
...
>>> f = F()
>>> f += 1, 2
(1, 2)

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web