# A new shorthand for Optional

**URL:** <https://discuss.python.org/t/a-new-shorthand-for-optional/58060>\
**Category:** Python Help\
**Tags:** typing\
**Created:** [July 13, 2024, 7:47am UTC](https://discuss.python.org/t/a-new-shorthand-for-optional/58060 "2024-07-13T07:47:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![billyeatcookies](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/billyeatcookies/32/21051_2.png) [@billyeatcookies](https://discuss.python.org/u/billyeatcookies)\
**Post date:** [July 13, 2024, 7:47am UTC](https://discuss.python.org/t/a-new-shorthand-for-optional/58060/1 "2024-07-13T07:47:49Z")

</div>

The pipe symbol `|` is used to represent Union in versions 3.10+.  
`Union[str, int]` can be abbreviated as `str | int`.

Additionally, `Optional[T]` can be simplified to `T | None` making use of union.

Of course, I realize that readability should take precedence over conciseness.  
My suggestion is to introduce a syntax like `T?` to abbreviate `Optional[T]`. Sorry if this is not a good proposal; please let me know of the problems with it.

---

<div class="post-metadata">

**Author:** ![layday](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/layday/32/2771_2.png) [@layday](https://discuss.python.org/u/layday)\
**Post date:** [July 13, 2024, 9:01am UTC](https://discuss.python.org/t/a-new-shorthand-for-optional/58060/2 "2024-07-13T09:01:09Z")

</div>

This was previously a PEP for which the sponsor withdrew support: [PEP 645 – Allow writing optional types as x? | peps.python.org](https://peps.python.org/pep-0645/).
