Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.05; 'assignment': 0.07; '"a"': 0.09; '(same': 0.09; 'parameter.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'stored': 0.10; 'python': 0.11; 'python.': 0.11; 'def': 0.14; 'applies': 0.15; 'thu,': 0.15; 'evaluated.': 0.16; 'message-id:@4ax.com': 0.16; 'notes"': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement.': 0.16; 'string': 0.17; 'basically': 0.18; 'url:home': 0.18; '>>>': 0.20; 'variable': 0.20; 'changes': 0.20; 'names.': 0.22; 'object.': 0.22; 'parameter': 0.22; '2015': 0.23; 'header:X -Complaints-To:1': 0.26; "doesn't": 0.28; 'actual': 0.29; 'expose': 0.29; 'pile': 0.29; 'function': 0.30; 'print': 0.31; 'entry': 0.31; 'fixed': 0.31; 'addresses': 0.32; 'common': 0.33; 'allocated': 0.33; 'change,': 0.33; 'shift': 0.33; 'another': 0.34; 'languages': 0.34; 'subject:?': 0.34; 'to:addr:python-list': 0.35; 'false': 0.35; 'but': 0.36; 'except': 0.36; '(and': 0.36; 'should': 0.37; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'instead': 0.38; '(with': 0.38; 'received:org': 0.38; 'names': 0.38; 'end': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'your': 0.60; 'address': 0.61; 'different': 0.64; 'dennis': 0.91; 'tied': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Can Python function return multiple data? Date: Thu, 04 Jun 2015 19:51:13 -0400 Organization: IISS Elusive Unicorn References: <3bbe49da-e989-4a8c-a8a9-75d3a786f508@googlegroups.com> <557056f9$0$13009$c3e8da3$5496439d@news.astraweb.com> <87a8wf5z4l.fsf@elektro.pacujo.net> <874mmn5xbb.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-73-119-127.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433461888 news.xs4all.nl 2856 [2001:888:2000:d::a6]:56235 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92108 On Thu, 04 Jun 2015 18:04:56 +0300, Marko Rauhamaa declaimed the following: > >Yes, but that would be a shift from the 1970's notion: > > In pass-by-value, the actual parameter is evaluated. The value of the > actual parameter is then stored in a new location allocated for the > function parameter. > Except that this does NOT happen with common Python. Python doesn't "store in a new location"... >>> def func(parm): ... print id(parm), id(a), parm is a ... parm = 6 ... print id(parm), id(a), parm is a ... >>> a = 3 >>> func(a) 4145800 4145800 True 4145728 4145800 False >>> print a, id(a) 3 4145800 >>> In the first print, "parm" and "a" ARE THE SAME OBJECT After the assignment to parm, "parm" and "a" are no longer the same object. In your "1970's notion", "parm" and "a" should already be different object by the time of the first print statement. In common Python, id() basically returns the address of the object. "a" is a reference to an object with the value "3"... On entry to func(), "parm" is aso a reference to the same object (same address/ID). But after the assignment, "parm" is now a reference to a different object. Python does not expose the old "mailboxes" concept to the user... That is: where the languages of the 50s-70s all tied variable names to fixed addresses (boxes) in memory, and assignment copies the contents of one box to another box (and this applies also to parameter passing), Python instead has a pile of "objects", a bunch of names on "post-it notes" (with strings attached to them), and assignment works by moving the string from one object to another object -- the location of the name does not change, only the other end of the string changes what object it names. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/