Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Sat, 21 Nov 2015 03:36:28 +1100 Lines: 22 Message-ID: References: <564dbe6b$0$1610$c3e8da3$5496439d@news.astraweb.com> <564df258$0$1604$c3e8da3$5496439d@news.astraweb.com> <564e71f6$0$1619$c3e8da3$5496439d@news.astraweb.com> <877flcrh26.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de KinULlpOp08g8GsSMj7oLA8kbigTk390bz6icp17n5zQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '21,': 0.07; 'mask': 0.07; 'cc:addr:python-list': 0.09; 'logic': 0.09; 'def': 0.13; 'argument': 0.15; 'cc:name:python': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'overloaded': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'suppresses': 0.16; 'wrote:': 0.16; 'try:': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'errors': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'usually': 0.33; 'except': 0.34; 'received:google.com': 0.35; 'ones': 0.35; 'c++': 0.35; 'nov': 0.35; 'but': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'cases': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'version': 0.38; 'received:209': 0.38; 'sure': 0.39; "didn't": 0.39; 'where': 0.40; 'default': 0.61; 'more': 0.63; 'different': 0.63; 'other.': 0.64; '20,': 0.66; 'improvement.': 0.66; "they're": 0.66; 'chrisa': 0.84; 'to:none': 0.91 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=rwPKBwXVfimPnrOlrwxUa40S6kxn+kxA7Kzlb5O3C+4=; b=pY0bl/hOBR8sqLQqn3CJx7LjZFoJ9XdYcAZQylYSIgMXZTPSXu5D/+mJQASaMnhaOw ZMbCOyVobN37WgkBjCOpqReRHdUn+LTAcHxSODvj50Yk7ACVSPWbvmTtG2C3bLs6pqUa fp49ViVouNwN1Zf1lFf1drf3YWdiJw1DMTqQaxnS2wjWfSK/SSkSh/WOErskwD5otGFV n4GY/Q+vIgjjESOaYOYDH7Y1NRk/f2HnUH02jffai4nRrVX6e9/XYyZ+FKBrOxlTTifX 6QP7XbKHzTZsuUQgUI1QI9lYdG7r5kZRHMZ8iwP4Rqr6C/z5NxgUPg2es1cMT3/mbJQe PkMQ== X-Received: by 10.50.83.38 with SMTP id n6mr865189igy.92.1448037388960; Fri, 20 Nov 2015 08:36:28 -0800 (PST) In-Reply-To: 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: , Xref: csiph.com comp.lang.python:99166 On Sat, Nov 21, 2015 at 3:29 AM, Ian Kelly wrote: > On Fri, Nov 20, 2015 at 9:24 AM, Chris Angelico wrote: >> The cases where that's not true are usually ones that are more like >> C++ overloaded functions: >> >> def next(iter): >> return iter.__next__() >> def next(iter, default): >> try: return iter.__next__() >> except StopIteration: return default > > IMO the version with the default argument should have a different > name, as it is conceptually a different function. Which would make it like dict.__getitem__ and dict.get, which leads to a lot of people using dict.get() because they don't know about subscripting. And then they mask potential errors because they're using the version that suppresses them, since they didn't even know about the other. Not sure that's an improvement. But I do see the logic in the separation. ChrisA