Episode 115: Digging Into PyScript & Preventing or Handling Python Errors
The Real Python Podcast
Jun 24, 2022 56m
Have you heard about PyScript? The brand-new framework has the community excited about building interactive Python applications that run entirely within the user’s browser. Would you like to dig into the details beyond the “Hello World” examples? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder’s Weekly articles and projects.
Episode Sponsor:
We talk about a Real Python tutorial from Bartosz Zaczyński about PyScript. The article provides an initial look at the framework and then takes you deep into the intricacies. We also share additional resources to help familiarize you with the project.
Christopher talks about another Real Python article, this one on how to approach managing errors in Python. The tutorial “LBYL vs EAFP: Preventing or Handling Errors in Python” is from frequent contributor Leodanis Pozo Ramos.
We cover several other articles and projects from the Python community, including discussing the PSF’s Python Developers Survey 2021 Results, Django static files and templates, how to profile Python code, a launcher for penetration testing, and a project for confirming Python versions through syntax errors.
Course Spotlight: Building a Django User Management System
In this video course, you’ll learn how to extend your Django application with a user management system, complete with email sending and third-party authentication.
Topics:
- 00:00:00 – Introduction
- 00:02:32 – LBYL vs EAFP: Preventing or Handling Errors in Python
- 00:08:38 – How To Profile Python Code
- 00:18:52 – Sponsor: CData Software
- 00:19:35 – Django Static Files and Templates
- 00:26:35 – A First Look at PyScript: Python in the Web Browser
- 00:38:20 – Video Course Spotlight
- 00:39:39 – Python Developers Survey 2021 Results
- 00:48:19 – python-syntax-errors: Version-Specific No-Ops
- 00:50:03 – arsenal: Inventory Launcher for Penetration Testing
- 00:55:03 – Thanks and goodbye
Topics Links:
- LBYL vs EAFP: Preventing or Handling Errors in Python – In this tutorial, you’ll learn about two popular coding styles in Python: look before you leap (LBYL) and easier to ask forgiveness than permission (EAFP). You can use these styles to deal with errors and exceptional situations in your code. You’ll dive into the LBYL vs EAFP discussion in Python.
- How To Profile Python Code – No matter how good you are, sometimes your code just runs slowly. Learning how to properly profile your software to identify and fix bottlenecks is a useful skill. This article talks about what you need to know to measure your code’s performance and how to use the cProfile,
profile
, andtimeit
libraries, along with others. - Django Static Files and Templates – “Static files like CSS, JavaScript, and fonts are a core piece of any modern web application. They are also typically confusing for Django newcomers since Django provides tremendous flexibility around how these files are used. This tutorial will demonstrate current best practices for configuring static files in both local development and production.”
- A First Look at PyScript: Python in the Web Browser – In this tutorial, you’ll learn about PyScript, a new framework that allows for running Python in the web browser with few or no code modifications and excellent performance. You’ll leverage browser APIs and JavaScript libraries to build rich, highly interactive web applications with Python.
Discussion:
- Python Developers Survey 2021 Results | PSF
- Python Developers Survey 2021 Results | JetBrains
- Raw Data SurveyExport.csv | Google Drive
Projects:
- python-syntax-errors: Version-Specific No-Ops
- arsenal: Inventory Launcher for Penetration Testing
- navi: An interactive cheatsheet tool for the command-line
- eg: Useful examples at the command line.
Additional Links:
- “Zero cost” exception handling · Issue #84403
- Python 3.11 Preview: Task and Exception Groups | Real Python
- PyCon US 2022 Keynote - Peter Wang - PyScript | YouTube
- PyScript | Run Python in your HTML
- pyscript: Getting started
- pyscript: Pyscript examples
- Python Timer Functions: Three Ways to Monitor Your Code | Real Python
- Amdahl’s law | Wikipedia
- Django Books | William Vincent
- Django Chat
- Episode #114: Getting Started in Python Cybersecurity and Forensics | The Real Python Podcast