Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Can Python function return multiple data? Date: Thu, 04 Jun 2015 18:04:56 +0300 Organization: A noiseless patient Spider Lines: 49 Message-ID: <874mmn5xbb.fsf@elektro.pacujo.net> References: <3bbe49da-e989-4a8c-a8a9-75d3a786f508@googlegroups.com> <557056f9$0$13009$c3e8da3$5496439d@news.astraweb.com> <87a8wf5z4l.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="26725"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EvV3J5Wv2+4flqjzmsW/q" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:ZaIKtYKEvWTjEPeVsjzjZVRFshw= sha1:ztSkezUplvJavODSEW97ygUqulo= Xref: csiph.com comp.lang.python:92063 Grant Edwards : >> Anyway, I would say Python definitely is in the classic pass-by-value >> camp. Here's a simple test: >> >> def f(x): >> x = 3 >> >> y = 1 >> f(y) >> print(y) >> >> If it prints 1, it's pass by value. If it prints 3, it's pass by >> reference. > > Somebody else might just as honestly say that it's pass by reference: 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. [...] In pass-by-reference, the actual parameter must have an L-value. The L-value of the actual parameter is then bound to the formal parameter. [...] * A parameter in Pascal is normally passed by value. It is passed by reference, however, if the keyword var appears before the declaration of the formal parameter. procedure proc(in: Integer; var out: Real); * The only parameter-passing method in C is call-by-value; however, the effect of call-by-reference can be achieved using pointers. In C++ true call-by-reference is available using reference parameters. Pass by reference could easily be added to Python, too, if that were deemed useful. Marko