## New Approach to Python Typing

From: andrew cooke <andrew@...>

Date: Mon, 18 Apr 2011 21:13:49 -0300

After releasing an inital version of pytyp I started writing up my ideas into
a paper.  That collected my thoughts more clearly and led to some new ideas,
which I am starting to fold back into pytyp.  Here's an example of the kind of
thing that will now be possible:

def test_list(self):
class Bar(list, Seq(int)): pass
bar = Bar([1,2,3])
assert isinstance(bar, Seq(int))
assert isinstance(bar, Sequence)
assert isinstance(bar, list)
assert bar[1:] == [2,3], bar[1:]
assert not isinstance(bar, Seq(float))

The motivation is to support a more pythonic approach - ie one that fits
better with existing ideas in the language.  So what I've done above is add
parametric polymorphism to the Sequence ABC (obviously it would be better to
not have a new class, called Seq, but I can't alter exiting Python libraries).

Andrew