DEV Community

Cover image for What's coming in Python 3.8?
petercour
petercour

Posted on

3

What's coming in Python 3.8?

What will be added to Python 3.8? Quite some changes. Don't know Python, it's a good time to start

  • The walrus operator

The walrus operator will be addded (:=). That's because with a bit of imagination it looks like a walrus.

m = re.match(p1, line)
if m:
    return m.group(1)
else:
    m = re.match(p2, line)
    if m:
        return m.group(2)
    else:
        m = re.match(p3, line)
        ...
Enter fullscreen mode Exit fullscreen mode

becomes:

if m := re.match(p1, line):
    return m.group(1)
elif m := re.match(p2, line):
    return m.group(2)
elif m := re.match(p3, line):
Enter fullscreen mode Exit fullscreen mode

  • Debug support for f-strings

What are f-strings you say? You can easily output stuff:

answer = 42
f'The answer is not {answer+1}'
f'The root of the answer is {math.sqrt(answer)}'
Enter fullscreen mode Exit fullscreen mode

A lot easier than adding + str(answer) and that kind of stuff.

  • Positional-only parameters
  • A movable pycache

and more things. Your old Python 3.x code will still work.

Related links:

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (1)

Collapse
 
grozail profile image
Ilya

And, moreover, changes in multiprocessing :)
"multiprocessing can now use shared memory segments to avoid pickling costs between processes"

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay