typing.Union[X, Y]
is used to declare that a variable can be either X
or Y
. In Python 3.10 and above, you can replace Union[X, Y]
with X|Y
.
Write Union Types with X|Y
Table of Contents

typing.Union[X, Y]
is used to declare that a variable can be either X
or Y
. In Python 3.10 and above, you can replace Union[X, Y]
with X|Y
.
CodeCut is a platform that offers short and visually appealing code snippets related to data science, data analysis, data engineering, and Python programming.
Copyright © 2025 Code Cut - All rights reserved.