When is an exception not an exception? Using warnings in Python

Reuven M. Lerner

Reuven M. Lerner

Teaching Python and data science around the world since 1995. Author of the books "Python Workout" and "Pandas Workout". Publisher of the "Better developers" newsletter. I spend each day trying to help people improve their Python skills.

    摘要

    Python's warnings are exceptions — but they're also distinct from exceptions, and are both used and trapped differently. In this talk, I'll introduce warnings, how to raise, trap, and redirect them, and show you best practices for their use. Many experienced developers don't know that Python's warning system supports filtering and suppressing warnings quite flexibly, based on a variety of parameters. You can thus turn certain warnings into (potentially fatal) exceptions, or ignore them entirely -- or enjoy the default behavior, in which they appear on the screen. In addition to showing you how you can create and display warnings, I'll also show you how you can create your own, and (perhaps even more significantly) give examples of when they're appropriate.

    說明

    影片

    地點

    R1

    時間

    第二天 • 13:25-13:55 (GMT+8)

    語言

    英文演講

    層級

    中階

    分類

    Python 核心