[Python-Dev] Revive the types sig?

Fredrik Lundh fredrik at pythonware.com
Wed Mar 14 17:33:23 CET 2001

Paul Moore wrote:
> Type annotations, as described so far, sound like a sanitised and formalised
> version of this:
>     def f(n):
>         assert type(n) == type(1)
> I can imagine *very* few places where an assert like this is of genuine
> practical use.
> Of course, if type annotations will *actually* formalise and support
> interfaces in some form, that's entirely different - I'm mostly neutral, about
> something like this.
>     def f(n):
>         assert <n supports the "integer" interface>

footnote: the correct way to spell this is:

         assert isinstance(n, type(1)) # or types.IntType

as you say,

         assert type(n) is type(1)

is mostly evil.

Cheers /F

More information about the Python-list mailing list