
Hi all, As of 3.10 (PEP 604) we've gotten syntactical support for a common type operation— namely, typing.Union[Type1, Type2] can now be written as Type1 | Type2 . This is achieved via overriding the __or__ method. I propose the ? symbol as sugar for typing.Optional, so that typing.Optional[MyType] can be written as MyType? . (Yes, this is lifted directly from C#.) Thoughts? Is it unnecessary now that we can write MyType | None as of 3.10? Thanks, Will

That's proposed in PEP 645 (https://www.python.org/dev/peps/pep-0645/). Personally I think it's not necessary, we should just write MyType | None. (Yes, this is directly from TypeScript.) On Sun, Aug 15, 2021 at 6:10 AM Will Bradley <derivativedude123@gmail.com> wrote:
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>

That's proposed in PEP 645 (https://www.python.org/dev/peps/pep-0645/). Personally I think it's not necessary, we should just write MyType | None. (Yes, this is directly from TypeScript.) On Sun, Aug 15, 2021 at 6:10 AM Will Bradley <derivativedude123@gmail.com> wrote:
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>
participants (2)
-
Guido van Rossum
-
Will Bradley