Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62568
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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 | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '22,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:How': 0.10; 'def': 0.12; 'once.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:variable': 0.16; 'tuple.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bonus': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'text,': 0.24; 'equivalent': 0.26; 'second': 0.26; 'post': 0.26; 'asking': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'dec': 0.30; 'getting': 0.31; 'apparently': 0.31; 'supposed': 0.32; 'text': 0.33; 'subject:from': 0.34; 'december': 0.35; 'executing': 0.36; 'subject:one': 0.36; 'to:addr :python-list': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'blank': 0.60; 'exchange': 0.63; 'subject:more': 0.64; 'subjectcharset:utf-8': 0.72; '(5)': 0.74; 'approach.': 0.91; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re: How can i return more than one value from a function to more than one variable |
| Date | Sun, 22 Dec 2013 19:57:56 -0500 |
| References | <40ddd2cf-483f-423b-9a4d-93f6a5e77df2@googlegroups.com> <8e01f218-ec00-4d01-ab82-53e1ea7670e2@googlegroups.com> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | dpc6744192029.direcpc.com |
| In-Reply-To | <8e01f218-ec00-4d01-ab82-53e1ea7670e2@googlegroups.com> |
| User-Agent | Groundhog Newsreader for Android |
| 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.4518.1387760206.18130.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1387760206 news.xs4all.nl 2871 [2001:888:2000:d::a6]:43701 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62568 |
Show key headers only | View raw
On Sun, 22 Dec 2013 15:41:06 -0800 (PST), Bob Rashkin
<rrashkin@gmail.com> wrote:
> On Sunday, December 22, 2013 4:54:46 PM UTC-6, dec...@msn.com wrote:
> > How am I supposed to do so I can return also a value to the
variable y WITHOUT printing 'Now x =', w, 'and y = ' , z a second
time ?
You are apparently asking 3 questions.
To exchange 2 values, use the tuple-unpack approach.
a, b = b, a
To get the equivalent of multiple return values, return a tuple.
def myfunc (a):
x = a*a
y = 2+a
return x, y
p , q = myfunc (5)
To avoid executing your print twice, call the function only once.
And a bonus one: to avoid my getting a blank message in this text
newsgroup, post in text, not html.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How can i return more than one value from a function to more than one variable Bob Rashkin <rrashkin@gmail.com> - 2013-12-22 15:41 -0800
Re: How can i return more than one value from a function to more than one variable Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-22 19:05 -0500
Re: How can i return more than one value from a function to more than one variable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-23 00:37 +0000
Re: How can i return more than one value from a function to more than one variable Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-22 22:17 -0500
Re: How can i return more than one value from a function to more than
one variable Dave Angel <davea@davea.name> - 2013-12-22 19:57 -0500
Re: How can i return more than one value from a function to more than one variable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-23 11:45 +1100
csiph-web