Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!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.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'static': 0.03; 'subject:Python': 0.05; 'indicates': 0.09; 'optional': 0.09; 'python': 0.10; 'hint': 0.16; 'shorthand': 0.16; 'wrote:': 0.16; 'case.': 0.18; '2015': 0.20; 'aug': 0.20; 'correctly.': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'sort': 0.25; 'checking': 0.27; 'handling': 0.27; 'message- id:@mail.gmail.com': 0.27; 'types.': 0.29; 'code': 0.30; "i'd": 0.31; 'useful': 0.33; 'received:google.com': 0.35; 'returning': 0.35; 'quite': 0.35; "isn't": 0.35; 'but': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'things': 0.38; 'takes': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'some': 0.40; 'your': 0.60; "you'll": 0.61; 'skip:u 10': 0.61; 'checker': 0.84; 'subject:Become': 0.84; 'to:name:python': 0.84; 'subject:Now': 0.91; 'suffer': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=01mbo1KQxS5CsTj1BBKfLj+2nq6GuEvRqev1PP7DXAU=; b=j30GUTu+6rjmWmD4iUIjObE3vtErO0irjddAJWaM6ZTo7pP1jRpAbfmjJ90GK+ATQ2 HkFSdqucVnuX3XVPpSAdkgiGXhwaNouxMu/h6CfBSiXTkBEW9zvR4a/ysm8HQtxPuwXb abNrhHbKJ7YWha3kgtAXsu8JiCwBist/3KPxgqhAquzKr6dTtRQQmyYbKLxvIMn8VixE ZdzJj6uHeYxXprbIXSlgx1T6uXisTqxycmGekkmAjwcHQuKCZ0oSLd8R8rjLRjAex88X 3/jtOH55oUMTil1mF7JqITYaGTqGPej5RV2R5t+YPp0lzwB182LBh7LpKHThk3DYPBZH +okg== X-Received: by 10.50.7.68 with SMTP id h4mr20187566iga.40.1438597648029; Mon, 03 Aug 2015 03:27:28 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <427038102.1314110.1438595894636.JavaMail.root@sequans.com> References: <427038102.1314110.1438595894636.JavaMail.root@sequans.com> From: Ian Kelly Date: Mon, 3 Aug 2015 02:26:48 -0800 Subject: Re: Python 3 May Become Relevant Now To: Python 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1438597650 news.xs4all.nl 2950 [2001:888:2000:d::a6]:40277 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:94924 On Mon, Aug 3, 2015 at 1:58 AM, Jean-Michel Pichavant wrote: > But if I get things right, with python 3.5 type hint checker, I'd be screwed, as it is spefificaly designed to track this kind of "problem". > What's the use of None then ? Any method returning None can only return None or suffer the type checker retribution. > > I don't get it. This is where you would use optional types. Optional[List[X]] is a shorthand for the type Union[List[X], None]. In fact static type checking can be quite useful in this sort of case. If you return Optional[List[X]] in one place, and you have some other method that takes in the value but simply indicates that it takes List[X], then the static checker will flag that as an error, and you'll know that a part of your code likely isn't handling the None case correctly.