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: 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 Subject: =?UTF-8?Q?Re:_How_can_i_return_more_than_one_value_?= =?UTF-8?Q?from_a_function_to_more_than=0A_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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Sun, 22 Dec 2013 15:41:06 -0800 (PST), Bob Rashkin 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