Results for “def”

Showing 1–10 of 71

  1. Challenge

    Settings with defaults

    Build a user's settings by copying the defaults and laying their own values on top with update(), so any setting they haven't changed falls back, then warn about unknown keys instead of saving them.

    Write the code Medium 2 stages dictionaries copy update defaults
  2. Challenge

    Shared default list

    …log=[]) remembers samples from earlier calls, because the default list is created once and shared. Predict it, prove the calls share one list, fix it with None as the default, then write a function…

    Fix the code Medium 3 stages functions default values mutable defaults None
  3. Challenge

    Prove the fix

    …the fixed add_sample() that would have caught the shared default list, then add checks that a log passed in is still the one that gets the sample, so a "fix" that breaks that can't pass either.

    Write the code Medium 2 stages testing assert regression tests default values
  4. Challenge

    Log formatter function

    …stay exactly the same: [T+00:12:05] INFO Engines nominal Define the function at the top: def format_log(t, level, msg): , with return f"..." inside, using its own parameter names. Then…

    Fix the code Easy 2 stages functions def return refactoring