Release of Python 3.8

Most interesting innovations:

  • Assignment expression:

    The new operator := allows assignment of values to variables within expressions. For example:
    if (n := len(a)) > 10:
    print(f"List is too long ({n} elements, expected <= 10)")

  • Positional-only arguments:

    It's now possible to specify which function parameters can be passed using named argument syntax and which cannot. Example:
    def f(a, b, \/, c, d, *, e, f):
    print(a, b, c, d, e, f)

    f(10, 20, 30, d=40, e=50, f=60) # OK
    f(10, b=20, c=30, d=40, e=50, f=60) # error, `b` cannot be a named argument
    f(10, 20, 30, 40, 50, f=60) # error, `e` must be a named argument

    This change gives developers a way to protect users of their APIs from changes in function argument names.

  • Support for f-strings = for self-documenting expressions and debugging:

    Sugar added for simplifying debugging/logging messages.
    n = 42
    print(f'Hello world {n=}.')
    # напечатает "Hello world n=42."

  • Fixed the continue keyword in the finally block (it didn't work before).

Miscellaneous:

  • You can explicitly specify the path to the bytecode cache instead of the default __pycache__.
  • Debug and Release builds use the same ABI.

Source: linux.org.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster