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


Groups > comp.lang.python > #94924 > unrolled thread

Re: Python 3 May Become Relevant Now

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2015-08-03 02:26 -0800
Last post2015-08-03 02:26 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python 3 May Become Relevant Now Ian Kelly <ian.g.kelly@gmail.com> - 2015-08-03 02:26 -0800

#94924 — Re: Python 3 May Become Relevant Now

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-08-03 02:26 -0800
SubjectRe: Python 3 May Become Relevant Now
Message-ID<mailman.1174.1438597650.3674.python-list@python.org>
On Mon, Aug 3, 2015 at 1:58 AM, Jean-Michel Pichavant
<jeanmichel@sequans.com> 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web