https://docs.python.org/3.8/whatsnew/3.8.html#porting-to-python-3-8
# A
>>> val = False
>>> print(val)
False
# B
>>> print(val := False)
False
# A
inputs = list()
while True:
current = input("Write something: ")
if current == "quit":
break
inputs.append(current)
# B
inputs = list()
while (current := input("Write something: ")) != "quit":
inputs.append(current)
# A
>>> def incr(x):
... return x + 1
...
>>> incr(3.8)
4.8
>>> incr(x=3.8)
4.8
# B
>>> def incr(x, /):
... return x + 1
...
>>> incr(3.8)
4.8
>>> incr(x=3.8)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: incr() got some positional-only arguments passed as keyword arguments: 'x'
>>> def incr(x, /, a="Hello"):
... return f"{greeting}, {name}"
...
>>> incr("Łukasz")
'Hello, Łukasz'
>>> incr("Łukasz", a="Awesome job")
'Awesome job, Łukasz'
>>> incr("Łukasz", "Awesome job")
'Awesome job, Łukasz'
>>> incr(x="Łukasz", a="Awesome job")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: incr() got some positional-only arguments passed as keyword arguments: 'x'
# A
def incr(number):
return 2 * number
# B
def incr(number: float) -> float:
return 2 * number
>>> style = "formatted"
>>> f"This is a {style} string"
'This is a formatted string'