Some PEP 505 fixes from Mark.
This commit is contained in:
parent
e3e40dd1d2
commit
d1a16cac54
14
pep-0505.txt
14
pep-0505.txt
|
@ -48,7 +48,7 @@ work in Python::
|
|||
>>> title ?? 'Default Title'
|
||||
'My Title'
|
||||
>>> title = None
|
||||
>>> title ?? 'Bar'
|
||||
>>> title ?? 'Default Title'
|
||||
'Default Title'
|
||||
|
||||
Similar behavior can be achieved with the ``or`` operator, but ``or`` checks
|
||||
|
@ -114,11 +114,11 @@ The ``None`` coalescing operator also has a corresponding assignment shortcut.
|
|||
|
||||
::
|
||||
|
||||
data ??= []
|
||||
files ??= []
|
||||
headers ??= {}
|
||||
params ??= {}
|
||||
hooks ??= {}
|
||||
data ?= []
|
||||
files ?= []
|
||||
headers ?= {}
|
||||
params ?= {}
|
||||
hooks ?= {}
|
||||
|
||||
The ``None`` coalescing operator is left-associative, which allows for easy
|
||||
chaining::
|
||||
|
@ -127,7 +127,7 @@ chaining::
|
|||
>>> local_default_title = None
|
||||
>>> global_default_title = 'Global Default Title'
|
||||
>>> title = user_title ?? local_default_title ?? global_default_title
|
||||
'My Title'
|
||||
'Global Default Title'
|
||||
|
||||
The direction of associativity is important because the ``None`` coalesing
|
||||
operator short circuits: if its left operand is non-null, then the right
|
||||
|
|
Loading…
Reference in New Issue