WebOptional[str] is just a shorthand or alias for Union[str, None]. It exists mostly as a convenience to help function signatures look a little cleaner. Update for Python 3.10+ you can now use the pipe operator as well. # Python < 3.10 def get_cars(size: Optional[str]=None): pass # Python 3.10+ def get_cars(size: str|None=None): pass SDMIa8wjH0f4 WebMeaning of optional in English optional adjective us / ˈɑːp.ʃ ə n. ə l / uk / ˈɒp.ʃ ə n. ə l / B2 If something is optional, you can choose if you want to do it, pay it, buy it, etc.: English is 7KoBrYC4rBI7 Optional[str] is just a shorthand or alias for Union[str, None]. It exists mostly as a convenience to help function signatures look a little cleaner. Update for Python 3.10+ you can now use the pipe operator as well. # Python < 3.10 def get_cars(size: Optional[str]=None): pass # Python 3.10+ def get_cars(size: str|None=None): pass nEdT0xFLMSJc Meaning of optional in English optional adjective us / ˈɑːp.ʃ ə n. ə l / uk / ˈɒp.ʃ ə n. ə l / B2 If something is optional, you can choose if you want to do it, pay it, buy it, etc.: English is mFYaRt2iYvfH
Get Price