Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62609
| 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 | <mail@simonsblog.co.uk> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'assign': 0.07; 'advance': 0.07; 'function,': 0.09; 'received:internal': 0.09; 'subject:How': 0.10; 'def': 0.12; 'assignment.': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'subject: \n ': 0.16; 'subject:variable': 0.16; 'tuple': 0.16; 'y):': 0.16; 'variable': 0.18; 'basically': 0.19; 'print': 0.22; 'switch': 0.26; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'supposed': 0.32; 'subject:from': 0.34; 'received:66': 0.35; 'subject:one': 0.36; 'vice': 0.36; 'thanks': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'header:Message-Id:1': 0.63; 'subject:more': 0.64; 'from:addr:mail': 0.83 |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=simonsblog.co.uk; h=message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= UenS7B9clh4yBFhk+02c55dLmG0=; b=LVqtsqXqKAgc8OjRX01q0GgCm8HDoL9l 9KNDmPEwfJrLyxSifwAUTyMKLS6nQi3wd/oerc30iMUPFehZkSMqteqz5d4TDflq 7a3q78Lq4antdSdpXMsePoBx4X52EIrtzgYOZCFW12HRD9/rMDV7FCZO9I4V9G/f K8TtYmE9mOs= |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=UenS7B9clh4yBFhk+02c55dLmG0=; b=gj9 +wtTwZHFEtyLYn65vFXuEfkN1bTXgmtp97lsbBzjiji6VGOvxCEfOTgy67R3ruAv MM4OZn88QlgabOD368zxN1Oy/mcuw5QoIWxMr7yTjVMzuiAr4Gpzn52RWu1YAdfV opVzA4W7VZpKJM37VmTbCkvxQDkjOBCUI9JzN5qI= |
| X-Sasl-Enc | iICbwQ8ip/SY1Ai+aXs1U+RyYp9RgM9vlCYXOwVBAjwM 1387791416 |
| From | Simon Hayward <mail@simonsblog.co.uk> |
| To | python-list@python.org |
| MIME-Version | 1.0 |
| Content-Transfer-Encoding | 7bit |
| Content-Type | text/plain |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-2b496f6a |
| In-Reply-To | <40ddd2cf-483f-423b-9a4d-93f6a5e77df2@googlegroups.com> |
| References | <40ddd2cf-483f-423b-9a4d-93f6a5e77df2@googlegroups.com> |
| Subject | Re: How can i return more than one value from a function to more than one variable |
| Date | Mon, 23 Dec 2013 09:36:56 +0000 |
| X-Mailman-Approved-At | Mon, 23 Dec 2013 10:52:17 +0100 |
| 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.4543.1387792338.18130.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1387792338 news.xs4all.nl 2936 [2001:888:2000:d::a6]:38257 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62609 |
Show key headers only | View raw
> 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
Using multiple assignment.
# Swap values
x, y = 4, 7
y, x = x, y
Or to keep this in a function, return a tuple and assign from that:
def switch(x, y):
return y, x
x, y = switch(x, y)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How can i return more than one value from a function to more than one variable dec135@msn.com - 2013-12-22 14:54 -0800 Re: How can i return more than one value from a function to more than one variable Simon Hayward <mail@simonsblog.co.uk> - 2013-12-23 09:36 +0000 Re: How can i return more than one value from a function to more than one variable Rick Johnson <rantingrickjohnson@gmail.com> - 2013-12-22 16:10 -0800 Re: How can i return more than one value from a function to more than one variable Gary Herron <gary.herron@islandtraining.com> - 2013-12-23 01:58 -0800
csiph-web