Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70953
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Marko Rauhamaa <marko@pacujo.net> |
| Newsgroups | comp.lang.python |
| Subject | Re: Pass variable by reference |
| Date | Tue, 06 May 2014 13:38:14 +0300 |
| Organization | A noiseless patient Spider |
| Lines | 23 |
| Message-ID | <87eh07i44p.fsf@elektro.pacujo.net> (permalink) |
| 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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="26595"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GMZQDrpdQ8IAM/aNUQHl2" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
| Cancel-Lock | sha1:NWUZlqkRiJwFOmpIS9qmjzD/Hek= sha1:B1qD/NCuiSErcu1IkFta7KKc6Vs= |
| Xref | csiph.com comp.lang.python:70953 |
Show key headers only | View raw
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. > And, by the way, it's not purely academic. There have been times when > I've done exactly that as a means of passing state around. It's not > common, but it has its place. Nobody has been disputing Steven's technique. There are many variations to that as well. For example, instead of a list, there might be an appropriate class/object that could host the interesting piece of information and act as the desired reference. Marko
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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