The Python Oracle

How to specify multiple return types using type-hints

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Cool Puzzler LoFi

--

Chapters
00:00 Question
00:31 Accepted answer (Score 858)
02:30 Answer 2 (Score 130)
03:11 Answer 3 (Score 97)
03:55 Answer 4 (Score 76)
04:59 Thank you

--

Full question
https://stackoverflow.com/questions/3394...

Accepted answer links:
[Union Type]: https://docs.python.org/3/library/stdtyp...
[type objects]: https://docs.python.org/3/library/stdtyp...
[type annotations]: https://docs.python.org/3/glossary.html#...
[typing.Union]: https://docs.python.org/3/library/typing...
[typing.Union]: https://docs.python.org/3/library/typing...
[PEP 484]: https://www.python.org/dev/peps/pep-0484/
[PEP 483]: https://www.python.org/dev/peps/pep-0483/
[What are type hints in Python 3.5?]: https://stackoverflow.com/questions/3255...
[PEP 484]: https://www.python.org/dev/peps/pep-0484/

Answer 2 links:
[typing.Tuple]: https://docs.python.org/3/library/typing...
[How to annotate types of multiple return values?]: https://stackoverflow.com/questions/4018...

Answer 3 links:
[Optional[X]]: https://stackoverflow.com/a/39429578/211...

Answer 4 links:
[Union]: https://docs.python.org/3/library/typing...
[starting with ]: https://docs.python.org/3.10/whatsnew/3....

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #python3x #typehinting #returntype #pythontyping

#avk47