Python 3.9 got released and it comes with new cool features:
1. Dictionary union:
a = {1: 'a', 2: 'b', 3: 'c'}
b = {4: 'd', 5: 'e'}
c = a | b
print(c)
[Out]: {1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'}
2. Type hinting. Allows you to write:
def sum_dict(var: dict[str, int]) -> int:
return sum(var[key] for key in var)
3. New string methods. Two new string methods for removing prefixes and suffixes have been added.
"Hello world".removeprefix("He")
[Out]: "llo world"
4. Python 3.9 uses a new parser, based on PEG instead of LL(1). Python users are not affected, but parser improvements would help to develop new language features faster.
Link
#python
@pythonicAi
>>Click here to continue<<