Python News

Python News: What's New From April 2022

by Geir Arne Hjelle community

April 2022 saw the return of the PyCon US conference in person in Salt Lake City. During the conference, Python developers met for the annual Language Summit, and Anaconda announced PyScript, a way to write Python directly inside HTML. Earlier in the month, the Python Software Foundation (PSF) welcomed its new executive director.

Read on to dive into the biggest Python news from the past month!

PyScript: Python in Your Browser

During his keynote at PyCon US, Anaconda CEO Peter Wang unveiled the PyScript project. PyScript allows you to write Python directly inside HTML and run it in your browser. Consider the following example:

HTML
<html>
<head>
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>

<body>
    <py-script> print('Hello, World!') </py-script>
</body>
</html>

Note the <py-script> tag, which can contain any valid Python code. In this case, this is the traditional Hello, World! greeting.

This is functioning code. You can copy the above code block into a file, such as hello.html, and save that file to your computer. Then you can open it in your browser, for example by using Ctrl+O or Cmd+O and selecting hello.html. Alternatively, you can test a similar example immediately on the PyScript demos page.

PyScript provides custom HTML tags, including <py-script>, which you saw above. There are several other tags as well, with many still in development. However, here are a couple that are immediately useful:

  • <py-env> lists packages that should be made available in the environment.
  • <py-repl> creates a working Python REPL to interact with the environment.

The following, slightly more involved, example shows how you can use these features:

HTML
<html>
<head>
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
    <py-env>
        - numpy
    </py-env>
</head>

<body>
    <h1 id="title">Magic Squares - Loading ...</h1>
    <py-script>
import numpy as np

# Initialize a magic square
magic = np.array([[6, 7, 2], [1, 5, 9], [8, 3, 4]])

# Update title to indicate that the page has finished loading
pyscript.write("title", "Magic Squares")
    </py-script>

    <py-repl id="magic-repl" auto-generate="true">
magic.sum(axis=0)
    </py-repl>
</body>
</html>

In this example, you declare that you want to use numpy in your environment. Then you import numpy, create an array that represents a magic square, and update the title on the page to indicate that the page is done loading. The REPL will be populated with code that you can run interactively on the web page that you’ve specified with the HTML. A typical session can look like the following:

Output of PyScript example in the browser

Note that pyscript.write() can interact with the Document Object Model (DOM) and update the contents of named HTML elements. Additionally, code you write in the REPL can use variables initialized in earlier code.

PyScript makes all of this possible by building on top of Pyodide. Pyodide provides CPython compiled to WebAssembly so that it can run in the browser or with Node.js. Additionally, Pyodide makes it convenient to call JavaScript from Python, and PyScript takes advantage of this to wrap JavaScript libraries like D3.

PyScript is still very much experimental, but the possibilities of this new framework are very exciting. We’re looking forward to following the development of PyScript going forward.

PyCon US 2022

The PyCon US conference is the largest annual gathering in the Python community. It’s been happening every year since 2003, but for the previous two years, the conference went virtual due to the COVID-19 pandemic.

From April 27 to May 3, about 1800 people attended PyCon in Salt Lake City. While the conference was back to an in-person event, the effects of the pandemic were notable: attendence was down compared to 2019, strong health and safety guidelines were in place, and an online option was offered.

As at any PyCon conference, the talks covered a diverse range of topics and were of great quality. All talks were recorded and will be posted on the PyCon Youtube channel once postprocessing is done. This year, there were five keynotes:

  • Łukasz Langa on typing and complexity
  • Sara Issaoun about the imaging of black holes
  • Peter Wang announcing PyScript
  • Thomas Wouters and Pablo Galindo Salgado about Python 3.11 and the work of the steering council
  • Naomi Ceder on building a great community

Additionally, Georgi Ker, Reuven Lerner, Anthony Shaw, and Lorena Mesa participated in a panel discussion about diversity and inclusion in Python:

Diversity and Inclusion panel at PyCon 2022: Georgi Ker, Reuven Lerner, Anthony Shaw, Lorena Mesa

The conference was held at the Salt Palace Convention Center. With ample space and long hallways, the venue provided many opportunities to meet with sponsors and other attendees. We at Real Python had our own booth this year, and it was great to meet many of our readers and members.

Although the doors have been closed for this year’s PyCon US, the planning has already started for the next edition. It’ll also be hosted in Salt Lake City, from April 19 to April 27, 2023.

Python Language Summit 2022

The Python Language Summit is an annual meeting where Python developers can share information and discuss challenges related to CPython and other implementations. This important event for the language typically takes place during the PyCon conference.

This year’s language summit discussed topics such as the future of the global interpreter lock (GIL), optimizations coming out of the faster-cpython and Cinder projects, and a possible change in how f-strings are parsed.

We’re looking forward to learning more about the topics that were presented at the language summit. As in earlier years, the PSF will summarize the discussions on their blog. This year, Alex Waygood will cover the presentations at the summit in a series of upcoming blog posts.

New PSF Executive Director

At the end of last year, Ewa Jodlowska stepped down as executive director of the Python Software Foundation (PSF) after about ten years of service.

On April 7, the PSF announced that Deb Nicholson would take the reins as PSF executive director. Nicholson has a wealth of experience from other open-source and nonprofit organizations, including the Open Source Initiative, OpenHatch, and the local Boston Python User Group.

We at Real Python welcome Deb Nicholson and are excited to see the continued development of the PSF.

What’s Next for Python

This month, Python news has been dominated by the excitement of PyCon US and the joy of being able to attend in-person conferences again. As the world is slowly returning to normal, more and more user groups, meetups, and conferences will go back to meeting in person. Are there any conferences you’re looking forward to?

What’s your favorite Python news story from April? Let us know in the comments. Happy Pythoning!

🐍 Python Tricks 💌

Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

Python Tricks Dictionary Merge

About Geir Arne Hjelle

Geir Arne Hjelle Geir Arne Hjelle

Geir Arne is an avid Pythonista and a member of the Real Python tutorial team.

» More about Geir Arne

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Master Real-World Python Skills With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

Master Real-World Python Skills
With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

What Do You Think?

Rate this article:

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal.


Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

Keep Learning

Related Tutorial Categories: community