A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/typing/issues/429 below:

Shorter syntax for Optional[...] · Issue #429 · python/typing · GitHub

Multiple people have suggested a shorter syntax to replace Optional[...]. The current syntax will become more inconvenient if we don't infer optional types from None default values (see #275).

Here are various options that I remember seeing proposed:

  1. x? or ?x

This would require new Python syntax.

Hack uses ?x. TypeScript uses x? for names, not types, if I've understood things correctly.

  1. x | None

This would require support for | for all type objects, which would not be backward compatible.

The | operator is used by TypeScript.

  1. {x}

Probably not an option as this is too cryptic. Suggested in #151 .

  1. from typing import Optional as O or from typing import Optional as Opt

This is not actually a new syntax and works currently. These are arguably inelegant.

feluxe, Naddiseo, NN---, perkfly, c6401 and 19 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4