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


Groups > comp.lang.python > #70955

Re: Pass variable by reference

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'correct,': 0.09; 'oh,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'library),': 0.16; 'naming': 0.16; 'parameters,': 0.16; 'pointers,': 0.16; 'python",': 0.16; 'python".': 0.16; 'semantically': 0.16; 'subject:variable': 0.16; 'tuple.': 0.16; 'for?': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; "shouldn't": 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; 'usually': 0.31; 'though.': 0.31; 'values.': 0.31; 'cases': 0.33; 'implemented': 0.33; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'returning': 0.36; 'words,': 0.36; 'doing': 0.36; 'should': 0.36; 'pm,': 0.38; 'that,': 0.38; 'even': 0.60; 'then,': 0.60; "you're": 0.61; 'first': 0.61; 'worth': 0.66; 'absolutely.': 0.84; 'characters,': 0.84; '"how': 0.91; 'to:none': 0.92
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=AvJRsVWwM2r1mIMtFwW7bL/jjqesZkqRiEzbYqXrowM=; b=xRPrUY4eKERN5jMRYg7D6GfzgRpQQY4Aysski+eYKa4a8ZdDzQf8A5V94qXq2QfdXb kxWqPjWXjPG5Js0dUvwEdJb7GfqIE63FG07v7QXd8bMbKb0gDrVwK6Og28UP/jI2DY87 2JLc2sd7VSbLRXGZV41INCNSZATpcRrEgZ5fCsMMmO5P7A563kkaQFYsdb3UFwH85Ayj UR6l0IiKfV2fmYl6f/4e5y8xAtrvyJcqL87syTYQEO2j30IHq8VKW8K86VXzkdOSb2wk gdpU54/HZEDsEextfaHfUAhsuyBfbamyYbh/zbFVBnQwqmJi5qw0LwRVJ3yYkmjSXogc 4DIA==
MIME-Version 1.0
X-Received by 10.58.116.175 with SMTP id jx15mr26168433veb.9.1399373120723; Tue, 06 May 2014 03:45:20 -0700 (PDT)
In-Reply-To <87eh07i44p.fsf@elektro.pacujo.net>
References <mailman.9690.1399348396.18130.python-list@python.org> <53689aeb$0$11109$c3e8da3@news.astraweb.com> <87lhufi85o.fsf@elektro.pacujo.net> <mailman.9694.1399369998.18130.python-list@python.org> <87eh07i44p.fsf@elektro.pacujo.net>
Date Tue, 6 May 2014 20:45:20 +1000
Subject Re: Pass variable by reference
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9696.1399373123.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1399373123 news.xs4all.nl 2934 [2001:888:2000:d::a6]:60256
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70955

Show key headers only | View raw


On Tue, May 6, 2014 at 8:38 PM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Chris Angelico <rosuav@gmail.com>:
>
>>>     characters, words, lines = stats.read()
>>
>> That's not really pass-by-reference, though. What you're doing is
>> output parameters, which are usually implemented in C with pointers,
>> but in Python with a return tuple.
>
> Correct, but it is worth questioning the question itself: what do you
> need pass-by-reference for? A very common case is returning multiple
> values. For that, Python has other idioms available.

Oh, absolutely. As in many other cases, you shouldn't ask "How do I do
<some non-Python idiom> in Python", but should ask "How do I
accomplish <some goal> in Python". Only in a few cases is the first
question reasonable (eg "How do I call this function from Python",
naming some function from a C library), and even then, it's
semantically arguable.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Pass variable by reference Satish Muthali <satish.muthali@gmail.com> - 2014-05-05 17:39 -0700
  Re: Pass variable by reference Rustom Mody <rustompmody@gmail.com> - 2014-05-05 21:32 -0700
  Re: Pass variable by reference Steven D'Aprano <steve@pearwood.info> - 2014-05-06 08:18 +0000
    Re: Pass variable by reference Marko Rauhamaa <marko@pacujo.net> - 2014-05-06 12:11 +0300
      Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-06 19:53 +1000
        Re: Pass variable by reference Marko Rauhamaa <marko@pacujo.net> - 2014-05-06 13:38 +0300
          Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-06 20:45 +1000

csiph-web