We have the `Optional[T]` type as a short-hand for Union[T | None] and telling 
us that said argument may not be present.

However, I find that a majority of the time, we also want to set a default 
value of None on the argument so that it can be evaluated without doing a 
getattr() check first.

iow, a lot of `foo: Optional[str] = None` in method signatures.

I'd love to see a companion to the Optional type, I'll call it Default, so that 
it can take a default value as a second arg, with a default of that being None. 

For example:

foo: Default[str] would be equivalent to foo: Optional[str] = None
foo: Default[str, "bar"] would be equivalent to foo: Optional[str] = "bar"

or something like that. Basically, any way to avoid writing `= None` over and 
over again.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to