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


Groups > comp.lang.python > #17646

Re: Please explain this for me

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <enalicho@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.01; '21,': 0.09; 'append': 0.09; 'none.': 0.09; 'am,': 0.12; 'def': 0.13; 'stored': 0.13; '4:39': 0.16; 'cc:addr:python-list': 0.16; 'received:74.125.82.44': 0.16; 'received:mail-ww0-f44.google.com': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'function': 0.27; 'all,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'list': 0.32; 'changes': 0.32; 'object': 0.33; 'someone': 0.34; 'received:74.125.82': 0.35; 'explain': 0.36; 'none': 0.37; 'subject:Please': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'could': 0.37; 'returned': 0.39; 'why': 0.39; "it's": 0.40; '2011': 0.61; 'here': 0.65; 'nothing.': 0.67; 'subject:this': 0.74; 'why?': 0.77
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=rIvek2eBOEiT9x8oj3nZ3rc9V11OKvLQzlT1K3lj18Q=; b=RFDFyKgS+tESztcB+dpr9pixVRYqr0tcHRHAuXz7e5eIgfDY70VKUiGalz5bluHTLg bPK69aEGE3fNncoUEJgNiU0ueXr4ikrU7Icp3Zy/1MTNJtZcOCpij4m2KfUhZQXc78BD KFaY0mnuIYQphnKhvKjVcgJ8ynHFxc0zQUV34=
MIME-Version 1.0
In-Reply-To <CAOypoo4YZUF9AWJVmL+7Po5Ew_fLyzyJmsA3b1qM8OJhNu0UXg@mail.gmail.com>
References <CAOypoo4YZUF9AWJVmL+7Po5Ew_fLyzyJmsA3b1qM8OJhNu0UXg@mail.gmail.com>
From Noah Hall <enalicho@gmail.com>
Date Wed, 21 Dec 2011 04:57:26 +0000
Subject Re: Please explain this for me
To Emeka <emekamicro@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3902.1324443488.27778.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324443488 news.xs4all.nl 6961 [2001:888:2000:d::a6]:38776
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17646

Show key headers only | View raw


On Wed, Dec 21, 2011 at 4:39 AM, Emeka <emekamicro@gmail.com> wrote:
>
> Hello All,

> v = []
>
> def add_to_list(plist):
>     u = plist.append(90)
>     return u
>
> add_to_list(v)  # This function call returns nothing
> Could someone explain why this function call will return nothing?

It's because add_to_list returns the value returned from plist.append
stored in u.
append changes a list in place and returns nothing. Functions that
return nothing return None. This is why it'll be None - u is None
because append returns None.


> add_to_list([])
> This one returns nothing, why?

It's because the object [] here has no name, so that you have no way
to refer to it after the function changes it, since it changes it in
place. It gets eaten by Python, never to be seen again.

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


Thread

Re: Please explain this for me Noah Hall <enalicho@gmail.com> - 2011-12-21 04:57 +0000

csiph-web