Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.05; 'pointers': 0.09; 'situation.': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.10; 'python': 0.11; 'wed,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nearest': 0.16; 'parameters,': 0.16; 'tuple,': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'saying': 0.22; 'function,': 0.22; 'am,': 0.23; '2015': 0.23; 'passing': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.24; 'equivalent': 0.27; 'message-id:@mail.gmail.com': 0.28; 'closer': 0.29; 'tutorial': 0.29; 'function': 0.30; 'values': 0.30; 'call.': 0.31; 'posts': 0.31; 'says': 0.32; 'common': 0.33; 'values.': 0.33; 'subject:?': 0.34; 'received:google.com': 0.34; 'returning': 0.35; 'possible.': 0.36; 'subject:: ': 0.37; 'say': 0.38; 'does': 0.39; 'data': 0.40; 'results': 0.66; 'chrisa': 0.84; 'to:none': 0.90 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:cc :content-type; bh=q0CV5b9y3jK3p+xU/YWy7e04yWwW6aNLVAhW2M6BuCo=; b=exYZCVv+ZdBMQGoYP65+uAGnKGjQVBCcLJDpCf/PGRY6e4YY+oV0Bamu44Q3A5nEA0 hK7yAfwxR6gU1fu7vK9BSE1dGHz8xJtCppo1/Wm7Uaf+2BWhikJQPsZVFYP2Yy75ceVV xncqKq0tWCAAH7s0Uuspsv6wFZikoHq7OQu9UwSdUBpQvlsgm/O1z4miIZQQt4+SuqqI mmUdjsjevklPxpY82uXxK3Y622ZzxodjaCZ1yePVj5CKebMN7PQXNaQwNW/iyo3v93FO 4ZCW7vIM23wF8yinMgEjCLNbNAXE/kp1sQnGOrEkr2z7bgxd8n/Qfp34rp1CN4mSV0F6 Lxzw== MIME-Version: 1.0 X-Received: by 10.107.160.141 with SMTP id j135mr37081357ioe.43.1433289397364; Tue, 02 Jun 2015 16:56:37 -0700 (PDT) In-Reply-To: <3bbe49da-e989-4a8c-a8a9-75d3a786f508@googlegroups.com> References: <3bbe49da-e989-4a8c-a8a9-75d3a786f508@googlegroups.com> Date: Wed, 3 Jun 2015 09:56:37 +1000 Subject: Re: Can Python function return multiple data? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433289398 news.xs4all.nl 2854 [2001:888:2000:d::a6]:39077 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91913 On Wed, Jun 3, 2015 at 7:27 AM, fl wrote: > I just see the tutorial says Python can return value in function, it does > not say multiple data results return situation. In C, it is possible. > How about Python on a multiple data return requirement? Technically, neither C nor Python can return multiple values from a single function call. In Python, the most common way to do this is to return a tuple, which can then be unpacked; as other posts in this thread have shown, this can look a lot like returning multiple values, and it's pretty convenient. In C, the nearest equivalent is passing a number of pointers as parameters, and having the function fill out values. Python's model is a lot closer to what you're saying than C's model is :) ChrisA