Default arguments in Python functions

This post is ba­sed on a gist I wro­te a whi­le ago, about why is ­not a good idea to pa­ss de­fault mu­ta­ble ob­jec­ts as pa­ra­me­ter­s in py­thon func­tion de­fi­ni­tion­s.

Whi­le the gist is ex­plai­ned th­rou­gh an exam­ple that uses lis­ts, the ­prin­ci­ple is appli­ca­ble to all sor­ts of ob­jec­ts (dic­tio­na­rie­s, se­ts, etc.).

If you are an ex­pe­rien­ced py­thon de­ve­lo­pe­r, you pro­ba­bly knew this ca­vea­t, ­ne­ver­the­le­ss is so­me­thing in­te­res­ting to show to new py­thon de­ve­lo­per­s, an­d ­to re­mem­ber even if you ha­ve been wri­ting co­de in Py­thon for year­s.