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


Groups > comp.lang.python > #62563

Re: How can i return more than one value from a function to more than one variable

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.023
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'advance': 0.07; '22,': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'def': 0.12; 'subject: \n ': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'basically': 0.19; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; '&gt;': 0.26; 'switch': 0.26; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'supposed': 0.32; 'url:python': 0.33; 'subject:from': 0.34; 'problem': 0.35; 'december': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:one': 0.36; 'vice': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'list': 0.37; 'list.': 0.37; 'whatever': 0.38; 'pm,': 0.38; 'subject:can': 0.39; 'sure': 0.39; 'url:mail': 0.40; 'how': 0.40; 'subject:more': 0.64; 'to:addr:gmail.com': 0.65; 'joel': 0.91; '2013': 0.98
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:to :cc:content-type; bh=pf/LkSTtqbqd+FV7SISRtlFKl8V4SgmfZjRDzAs2c3w=; b=icUu+0K+zNFo+rQkbmv2L4C1rIJiQYnPCSXyHteOWqFu80ehzWB3tYGX0G93yL4Qmx +1QRl62e1l3UIrqf5piShPco18Wu1Jcn3ZUiaYzXFLiOagjXjVDkZ0LfUCGJDxWUDyY5 tpuHeFKkOo8qe/BufBMb/FTsx41RewTTpYR5p8+dQAY6Y6X2sHLdoQLtQuIHjBBXAtwg QrU5lzONaBBKSYCp47gEIza/ZYdFv9k9KaG6dCXxRj2aC2XbpDIND4evMvgqosRCtF3J n2tH5sIMgTOd5WyFK9e2cjxGNnnuu3vAo48vsd7UsJWd/MpCxQE2zxnUoixm4Ki2i2Km yh6g==
MIME-Version 1.0
X-Received by 10.52.165.210 with SMTP id za18mr292315vdb.20.1387757137304; Sun, 22 Dec 2013 16:05:37 -0800 (PST)
In-Reply-To <8e01f218-ec00-4d01-ab82-53e1ea7670e2@googlegroups.com>
References <40ddd2cf-483f-423b-9a4d-93f6a5e77df2@googlegroups.com> <8e01f218-ec00-4d01-ab82-53e1ea7670e2@googlegroups.com>
Date Sun, 22 Dec 2013 19:05:37 -0500
Subject Re: How can i return more than one value from a function to more than one variable
From Joel Goldstick <joel.goldstick@gmail.com>
To Bob Rashkin <rrashkin@gmail.com>
Content-Type multipart/alternative; boundary=001a11c2048e34243504ee286366
Cc "python-list@python.org" <python-list@python.org>
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.4517.1387757150.18130.python-list@python.org> (permalink)
Lines 116
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387757150 news.xs4all.nl 2907 [2001:888:2000:d::a6]:59037
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62563

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

return a tuple:

return a, b, c

or whatever


On Sun, Dec 22, 2013 at 6:41 PM, Bob Rashkin <rrashkin@gmail.com> wrote:

> On Sunday, December 22, 2013 4:54:46 PM UTC-6, dec...@msn.com wrote:
> > basically what I wanna do is this :
> >
> >
> >
> > x = 4
> >
> > y = 7
> >
> > def switch (z,w):
> >
> > ***this will switch z to w and vice verca***
> >
> >      c= z
> >
> >      z=w
> >
> >      w=c
> >
> >      print 'Now x =', w, 'and y = ' , z
> >
> >      return w
> >
> > x = switch(x,y)
> >
> >
> >
> >  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 ?
> >
> >
> >
> > thanks in advance
>
> Not sure I understand the problem but I think the answer is to put
> multiple values in a list and return the list.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

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


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