Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:188.220': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:None': 0.09; 'api': 0.11; 'mean,': 0.16; 'missing,': 0.16; 'sequence,': 0.16; 'subject:design': 0.16; 'subject:versus': 0.16; 'def': 0.16; 'functions,': 0.19; 'wrote': 0.21; 'maybe': 0.22; 'values.': 0.23; 'subject: -- ': 0.25; "i'm": 0.27; 'ignored.': 0.29; 'etc.,': 0.30; 'values': 0.31; 'rather': 0.33; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; '...': 0.34; "can't": 0.34; 'error.': 0.36; 'designing': 0.37; 'some': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'steven': 0.38; 'should': 0.39; 'to:addr:python.org': 0.39; 'missing': 0.40; 'your': 0.60; 'received:188': 0.69; 'lightweight': 0.84; 'received:bethere.co.uk': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Rob Williscroft Subject: Re: None versus MISSING sentinel -- request for design feedback Date: Fri, 15 Jul 2011 07:43:57 +0000 (UTC) References: <4e1fd009$0$29986$c3e8da3$5496439d@news.astraweb.com> X-Gmane-NNTP-Posting-Host: 188-220-43-229.zone11.bethere.co.uk User-Agent: Xnews/5.04.25 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310715856 news.xs4all.nl 23928 [2001:888:2000:d::a6]:32925 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9516 Steven D'Aprano wrote in news:4e1fd009$0$29986$c3e8da3 $5496439d@news.astraweb.com in gmane.comp.python.general: > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should be just ignored. E.g.: > > mean([1, 2, MISSING, 3]) => 6/3 = 2 rather than 6/4 or raising an error. If you can't make your mind up then maybe you shouldn't: MISSING = MissingObject() def mean( sequence, missing = MISSING ): ... Rob.