[Python-ideas] Conventions for function annotations

Andrew Svetlov andrew.svetlov at gmail.com
Thu Dec 6 15:17:35 CET 2012


On Wed, Dec 5, 2012 at 9:22 PM, Guido van Rossum <guido at python.org> wrote:
> - Unions. We need a way to say "either X or Y". Given that we're
> defining our own objects we may actually be able to get away with
> writing e.g. "Int | Str" or "Str | List[Str]", and isinstance() would
> still work. It would also be useful to have a shorthand for "either T
> or None", written as Optional[T] or Optional(T).

Just to note: there are https://github.com/Deepwalker/trafaret library
intended for checking on complex enough structures.



More information about the Python-ideas mailing list