Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.039 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'argument': 0.05; 'args': 0.07; '(self,': 0.09; 'def': 0.12; '(1,': 0.16; 'args:': 0.16; 'tuple.': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'message- id:@mail.gmail.com': 0.30; 'way?': 0.31; 'class': 0.32; 'fri,': 0.33; 'skip:_ 10': 0.34; 'could': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'mar': 0.68; '20,': 0.68; 'results': 0.69; '2015': 0.84; 'abandon': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=7Oa65N20QM2eS3nDMEL8RUGZq7ftUAPfChmnm5PWtG0=; b=gUQXLhQCrFRheethYDStD8+QkNyvV6XKa1xFTOWL1Ayu1CjycrGDL6/OyY+9uSqVQ/ jZ9j0hvJ6JbghTGIUJW/tBY5JaftJHsIendoSn4kPyt2UGfKMCHPjVx2tpCF8e40YZH8 9xTPqlsl1F4d81KyuQ5Y9pOIa0u3k56gLUFqBTmBxh87Fx25NvSjqF9FdSsggXKCL+Do FQODUz6BZz298E0PUb2gcEr/d/3u7a4fNAmvPpLAhWmmfcEIQlDoqGhlbn12wsLnRj2x pVpvmncWPuWKO6IuGIY+N8HnLDBCutHqpDICcO4piIaXEpi5Fy1r/bj9WJtOxKvyatUX Sgww== X-Received: by 10.68.239.104 with SMTP id vr8mr78775pbc.96.1426887262435; Fri, 20 Mar 2015 14:34:22 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Fri, 20 Mar 2015 15:33:42 -0600 Subject: Re: __iadd__ with 2 args? To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1426887270 news.xs4all.nl 2957 [2001:888:2000:d::a6]:51385 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87797 On Fri, Mar 20, 2015 at 3:25 PM, Neal Becker 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)