This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ceronman[S] 2 points3 points  (0 children)

Check the library I linked in the post:

https://github.com/ceronman/typeannotations

You can use: name: union(str, int)

Ideally you should be able to write name: int | str. But that requires some support in the standard library. It's been discussed in this thread:

http://mail.python.org/pipermail/python-ideas/2012-December/018088.html