Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'subject:Python': 0.05; 'assignment': 0.07; 'calls.': 0.07; 'follows.': 0.09; 'semantics': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; 'question.': 0.13; 'def': 0.14; 'argument': 0.15; 'languages,': 0.15; "(it's": 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'magic': 0.16; 'received:mail- ig0-x22a.google.com': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'compare': 0.20; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'so.': 0.22; 'am,': 0.23; '2015': 0.23; 'passing': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.24; 'rules': 0.27; 'separate': 0.27; 'message-id:@mail.gmail.com': 0.28; "i'm": 0.29; 'follows': 0.29; 'no,': 0.29; 'function': 0.30; 'connection': 0.30; 'fri,': 0.31; 'option': 0.31; "d'aprano": 0.33; 'exhibit': 0.33; 'steven': 0.33; 'subject:?': 0.34; 'received:google.com': 0.34; 'something': 0.35; 'but': 0.36; 'two': 0.37; 'subject:: ': 0.37; 'difference': 0.38; 'rather': 0.38; 'is,': 0.38; 'seem': 0.39; 'real': 0.61; 'connection,': 0.72; 'chrisa': 0.84; 'to:none': 0.90; 'edwards': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=rnHiWVCMQp7G+ieA92aIqg92dsrzi55wdtmU1sgVYsI=; b=rIdzPb9xtwE/CdNP8l8vZkjZhmXIDMSc6fJe19XxFbBSVhGY3CPtoD/oh0l2Q/54Fz RcLuFMC5jzrMEvNOwBSdpMkJqeyUUaLtfFO9FXLe2yST9UmNDVb2lfos4+OBtLMvFKjG AhxaEi/hpa9m2CKhRSjfUDrsMp4Au9kVuHn7p3mS0CTNFVDfssf1AR4xAS0Vl0rtjw6e lIk8IJfI3c4eL+Q2xM0tUlENAHnEDDENwFHOhsJ4taX+kMNmCx4tWq1oAhyu1XVnTIjt a9bKQWWejcD3ec2/KFoxHoRrqKjFjtq/2WllqAmg0ViP50d7MXXbZuDwbpeZJ4pH/gmz OOWQ== MIME-Version: 1.0 X-Received: by 10.50.61.241 with SMTP id t17mr8534704igr.34.1433459091411; Thu, 04 Jun 2015 16:04:51 -0700 (PDT) In-Reply-To: <5570d6b3$0$12993$c3e8da3$5496439d@news.astraweb.com> References: <3bbe49da-e989-4a8c-a8a9-75d3a786f508@googlegroups.com> <557056f9$0$13009$c3e8da3$5496439d@news.astraweb.com> <87a8wf5z4l.fsf@elektro.pacujo.net> <557086d6$0$13011$c3e8da3$5496439d@news.astraweb.com> <5570d6b3$0$12993$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 5 Jun 2015 09:04:51 +1000 Subject: Re: Can Python function return multiple data? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433459100 news.xs4all.nl 2855 [2001:888:2000:d::a6]:34567 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92101 On Fri, Jun 5, 2015 at 8:52 AM, Steven D'Aprano wrote: > On Fri, 5 Jun 2015 04:38 am, Grant Edwards wrote: > >>>> But, discussing pass-by-this vs. pass-by-that without also discussing >>>> the semantics of the assignment operator is rather pointless. >>> >>> No, that's a red-herring. >> >> I don't think so. The reason that many people seem to confused about >> Python's argument passing is that they don't understand what >> assignment does. > > > I don't see the connection, but do explain, I'm interested. The connection is that argument passing is, in Python and in many other languages, a form of assignment, and follows all the same rules as assignment follows. (It's a kind of magic assignment that spans two namespaces, but that has nothing to do with pass-by-X questions.) These two will exhibit the same behaviour: # Option 1 x = some_object() y = x ... do something with y ... ... compare y and x # Option 2 def do_stuff(y): ... do something with y ... x = some_object() do_stuff(x) ... compare y and x Python's object semantics go far deeper than just argument passing, but everyone's confusions about pass-by-X are always about function calls. Whether this makes a real difference to anything is a separate question. ChrisA