Python 3.8 e lokolloa

Lintho tse ncha tse khahlisang haholo:

  • Tlhaloso ea mosebetsi:

    E ncha := opareitara e u lumella ho abela boleng ho mefuta e ka har'a polelo. Ka mohlala:
    haeba (n := len(a)) > 10:
    print(f"Lenane le lelelele haholo ({n} likarolo, li lebelletsoe <= 10)")

  • Likhang tsa maemo feela:

    Hona joale o ka hlakisa hore na ke li-parameter life tse ka fetisoang ka syntax e bitsoang argument le e ke keng ea khona. Mohlala:
    def f(a, b, /, c, d, *, e, f):
    hatisa(a, b, c, d, e, f)

    f(10, 20, 30, d=40, e=50, f=60) # HO lokile
    f(10, b=20, c=30, d=40, e=50, f=60) # phoso, `b` e ke ke ea e-ba khang e bitsoang
    f(10, 20, 30, 40, 50, f=60) # phoso, `e` e tlameha ho ba khang e rehelletsoeng

    Phetoho ena e fa ba ntlafatsang mokhoa oa ho sireletsa basebelisi ba li-API tsa bona liphetohong tsa mabitso a likhang tsa mosebetsi.

  • Tšehetso ea li-f-strings = bakeng sa lipolelo tsa ho ingolla le ho lokisa liphoso:

    E kentse tsoekere ho nolofatsa melaetsa ea ho lokisa liphoso / ho rema lifate.
    n = 42
    hatisa(f'Dumela lefatshe {n=}.')
    # e tla hatisa "Hello world n = 42."

  • Lokisa lentsoe la sehlooho la ho tsoela pele ho thibela (e ne e sa sebetse pele).

Tse ling:

  • U ka hlakisa ka ho hlaka tsela e eang ho cache ea bytecode sebakeng sa __pycache__ ea kamehla.
  • Debug le Release li aha sebelisa ABI e tšoanang.

Source: linux.org.ru

Eketsa ka tlhaloso