On Aug 29, 2019, at 12:09, Dominik Vilsmeier <dominik.vilsme...@gmx.de> wrote: > > What about using `(int, str)` for indicating a `Union`? This doesn't have > compatibility issues and it's similar to `isinstance(foo, (int, str))`, so it > should be fairly intuitive: > > def bar(foo: (int, str) = 0): > ...
In most languages with similar-ish type syntax, (int, str) means Tuple[int, str], not Union[int, str]. Scala and TypeScript copied this from ML just like Haskell and F# did. And I’d bet this is the main reason that {str, int} rather than (str, int) was proposed the first time around. But, balanced against the long-standing Python-specific use of tuples for small numbers of alternatives, including alternative types in places like isinstance, except, etc.? Maybe that beats the cross-linguistic issue. Either one seems a lot better than breaking backward compatibility by adding new operator methods to the type type. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XBSF3IU5SMIQZS527M6TXV5KOFRZXYXF/ Code of Conduct: http://python.org/psf/codeofconduct/