with (CtxManager1() as example, CtxManager2()): ...
with (CtxManager1(), CtxManager2() as example): ...
with ( CtxManager1() as example1, CtxManager2() as example2 ): # 變成 with ( CtxManager1() as example1, CtxManager2() as example2, CtxManager3() as example3, ):
終於有 switch 了,讚讚
1 2 3 4 5 6 7 8 9 10 11 12
defhttp_error(status): match status: case 400: return"Bad request" case 404: return"Not found" case 418: return"I'm a teapot" case 401 | 403: return"qqqqq" case _: return"Something's wrong with the internet"
1 2 3 4
defsquare(number: int | float) -> int | float: return number ** 2
isinstance(1, int | str)
3.9
Type Hinting Generics In Standard Collections
再也不用 import typing
before
1 2 3
from typing importList defgreet_all(names: List) -> None: # your code here
after
1 2
defgreet_all(names: list[str]) -> None: # your code here