Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.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.044 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'raises': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'def': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'keyword,': 0.16; 'subscripting': 0.16; 'troll': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'value.': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'instead.': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'raise': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; '"",': 0.31; "d'aprano": 0.31; 'keyerror:': 0.31; 'steven': 0.31; 'file': 0.32; 'quite': 0.32; '(most': 0.33; 'fri,': 0.33; 'moment': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'returning': 0.36; 'subject:?': 0.36; 'recent': 0.39; 'sure': 0.39; 'such': 0.63; 'effectively': 0.66; 'subject:. ': 0.67; 'between': 0.67; 'mar': 0.68; 'anything.': 0.68; 'again?': 0.84; 'distinguish': 0.84; 'seriously,': 0.84; 'to:none': 0.92 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=MRm0f1/GncwyvRRHmGrGpUt2OPcATsaIukIe4uwEXzY=; b=U4qPGVOeQUN0HVDJvohZWo1CzghmpQ+zBDurLl46w33MNppN4WagEZsXBwQJU6/WrU 67+RqaJwXnzaK8kEYMTyGvWEpFlaX6UCMplMbg8Me5nIyC75ObujSnD8NoKUf7RkosO5 ejPSZfL93UvzbNksY41lTAiFFHQ6DhC050oWONuczNe0t5W5EoZnx+KlZbNfZC8GTyqK BtymMsT3Geg/qhMqTGjpnCnBnPFnNnEIx25UDHTRfk8bJnNTwKx13ZaLTq9U2m49PqJf gdGiwfBUMx8D23XIAyVU8FrutiFOG1WUbHeYUD9lTLejSDny6M2MAfGe+Zj/rlsZKRZF wflg== MIME-Version: 1.0 X-Received: by 10.66.27.202 with SMTP id v10mr5410517pag.127.1394754944875; Thu, 13 Mar 2014 16:55:44 -0700 (PDT) In-Reply-To: <5322420e$0$29994$c3e8da3$5496439d@news.astraweb.com> References: <53206e6a$0$2886$e4fe514c@news2.news.xs4all.nl> <53207d77$0$2886$e4fe514c@news2.news.xs4all.nl> <5320e8c9$0$29994$c3e8da3$5496439d@news.astraweb.com> <87y50el1vf.fsf@elektro.pacujo.net> <5322420e$0$29994$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 14 Mar 2014 10:55:44 +1100 Subject: Re: Deep vs. shallow copy? 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.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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394754947 news.xs4all.nl 2903 [2001:888:2000:d::a6]:50197 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68343 On Fri, Mar 14, 2014 at 10:41 AM, Steven D'Aprano wrote: > Are you trolling again? > > I'm sure that you know quite well that Python doesn't have a procedure > type. It uses a single keyword, def, for creating both functions and > functions-that-return-None. I'm going to troll for a moment and give you a function that has no return value. def procedure(): raise Exception But seriously, this is something that some functions do when they need to distinguish between returning something and not returning anything. Look at a dictionary's subscripting (which is effectively a function call): >>> x={1:2} >>> x[1] 2 >>> x[3] Traceback (most recent call last): File "", line 1, in x[3] KeyError: 3 It can't return None to indicate "there was no such key in the dictionary", so it raises instead. There's only one way for a Python function to not have a return value: it has to not return. ChrisA