PythiloLesson 4 of 15 · progress kept in this browser

Logging

print is for your program's output. logging is for messages about what the program is doing, with levels that can be filtered without editing the code.

import logging

log = logging.getLogger("orders")

def charge(amount):
    log.info("charging %s", amount)
    if amount > 1000:
        log.warning("large: %s", amount)
  • Levels rise from DEBUG through INFO, WARNING and ERROR to CRITICAL.
  • A logger has a dotted name, and messages travel up to its parents.
  • Handlers decide where messages go. Applications configure them, libraries do not.
Your task

Write parse_quantities(rows) converting strings to ints and returning the list of good values. Using a logger named "orders", log a WARNING containing the text of each bad row, then one INFO at the end containing the count of good rows. Print nothing.